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.

Different evaluation in _exists and _assertExists

fnc-d16fnc-d16 Members
edited November -1 in Sahi - Open Source
By common sense, I'd expect that from passing _assertExists(X) results _exsists(X)==true.
But it turned out, in general, this doesn't hold. I run into a case where _assertExists(X) passes (green), but the following _exsists(X) ends up with an evaluation error "JSERROR
TypeError: Cannot call method "_cell" of undefined".
Surprisingly, _click(X) proceeds as expected - seems a little strange?

The very example tries to click an image in a cell in the last row of a table in a popup:
_popup("locator")._click(_image("",_in(_cell(3, _in(_row(_byId("explorer").rows.length-1, _in(_byId("explorer")))))))); // this works

_exists(_popup("locator")._cell(3, _in(_row(_byId("explorer").rows.length-1, _in(_byId("explorer")))))) // gives the error as wel as
_popup("locator")._exists(_cell(3, _in(_row(_byId("explorer").rows.length-1, _in(_byId("explorer"))))))

Needless to say tha all these expressions do fine in the controller's expression evaluation area.

Any advice?
Thanks

Comments

  • narayannarayan Administrators
    Hi fnc-d16,

    We are making the _popup related APIs a little cleaner.
    Meanwhile you can use this:
    $imageExists = false;
    _popup("locator")._set($imageExists, _exists(_popup("locator")._cell(3, _in(_row(_byId("explorer").rows.length-1, _in(_byId("explorer")))))) )
    
    // use $imageExists
    if ($imageExists) {
      // do my stuff
    }
    

    Regards,
    Narayan
Sign In or Register to comment.