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.

using if

escapeescape Members
edited November -1 in Sahi - Open Source
Hi

In the documentation there is a warning : _assertNotNull / _assertNull .....

DO NOT USE THIS IN AN IF CONDITION as it does not return any value, and throws an exception if the object is null.

But If I [Test-->] this API Function I get the value true (assertNotNull(spandiv("somespandiv")), true in grey box below) --> how can I get this value,

I want to give my testscript more flexibility with if , in my case

if ( the element not there )
{do this }
else { do that }

if ( _assertNull (_spandiv("somespandiv"))==true)
.......
doesn't work

How can I do this assertion with Sahi functions ???

regards escape

Comments

  • Hi

    I have found a solution, but for later releases it would be nice if the assert Functions return some values ......

    Solution:

    if ( _containsHTML(_byId("FOOTER"), "ERROR-sth went wrong")==false)
    { do it }

    // if there is no error do it .... : D
  • narayannarayan Administrators
    if (_condition(spandiv("somespandiv") == null)){
      // do this
    }else{
      // do that
    }
    
Sign In or Register to comment.