18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

sahi if condition

edited November -1 in Sahi - Open Source
hi Every one i am new to sahi and to automation testing

i am using a if condition to logout
if the user name matches then i should logout.
i use the below code to do that

if (_condition((_assertEqual("dmt Testingq", _getText(_span(11))))))
{
_click(_link("Logout"));
}

but when i ever i playback i see the below entry in the logs and it fails

_sahi.saveCondition("__lastConditionValue__0", (_assertEqual("dmt Testingq", _getText(_span(11)))))

Can any one please help me ......

Comments

  • globalwormingglobalworming Moderators
    edited March 2011
    remember: asserts dont return boolean values^^
    use if(_condition("text" == _getText(_span()))) {
  • Thanks globalworming for your reply but i dont how the below is script started working

    if (_condition((_assertEqual("dmt Testingq", _getText(_span(11))))))
    {
    _click(_link("Logout"));
    }
  • Sorry when I don't understand you right, but

    if (_condition((_assertEqual("dmt Testingq", _getText(_span(11))))))
    {
    _click(_link("Logout"));
    }

    will never work. If conditions require a boolean value

    if ( true ) { } else { }

    Please consider this http://sahi.co.in/w/_assertequal with a close view on the text in capitals at the bottom.

    For getting this thing to work, you need a boolean expression. Please change your code as follows

    if (_condition(( "dmt Testingq" == _getText(_span(11)))))
    {
    _click(_link("Logout"));
    }
Sign In or Register to comment.