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.

if statement always true

romainromain Members
edited April 2010 in Sahi - Open Source
Hi everybody,
Sorry by advance for the grammatical errors, I'm not english.

I got a little trouble,
At the beginning of my test, I'd like to see if I'm log on.
So, I' want to verify if the link "log-out" appear.
I write
if(_containsHTML(_link("Log-out"),"Log-out"))
...
But it's always true. same with _containsText
Do you have any idea?

Thanks so much

Comments

  • narayannarayan Administrators
    Hi Romain,

    Use _condition for if conditions which depend on the browser. Example

    if(_condition(_containsText(_link("Log-out"),"Log-out")))

    The proper way to do what you want is:

    if(_condition(_exists(_link("Log-out"))))

    Regards,
    Narayan
  • romainromain Members
    That works!
    Thank you!
  • Hi all,

    On a similar note to this question, I'd like to test if a link does NOT exists. I don't see a _notExists method or the like. How might I do this?

    Thanks,
    Brian
  • narayannarayan Administrators
    Use a regular ! for not

    if(!_condition(_exists(_link("Log-out"))))
  • Great. Thanks Narayan...

    B
This discussion has been closed.