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.

Problem in playback

KareemJKareemJ Members
edited November -1 in Sahi - Open Source
Hello,
I have a problem with playback.
I have a function (below), when it's played back, the function gets stuck in the while loop.
BUT if during the playback, I pause and go to "Evaluate expression" box and paste that function and click on "Test-->", it works as designed.
I tried to move the function and call it from different locations, but it always gets stuck in the while loop.

function getNumberInternal(){
_log("Start getNumberInternal", "success");
var $i=0;
while(_exists(_checkbox($i, _in(_div("div_dijits_0"))))){
++$i;
_alert("in while" + $i);
}
}

getNumberInternal();



Do you have any ideas?

Comments

  • narayannarayan Administrators
    Kareem,

    The condition _exists(_checkbox($i, _in(_div("div_dijits_0"))))
    needs to be wrapped in _condition.
    function getNumberInternal(){
        _log("Start getNumberInternal", "success");
        var $i=0;
        while(_condition(_exists(_checkbox($i, _in(_div("div_dijits_0")))))){
            ++$i;
            _alert("in while" + $i);
        }
    }
    

    The Evaluate Expression box evaluates javascript directly on the browser. A Sahi script actually executes inside a rhino engine in the proxy's Java process. In the proxy, _exists(_checkbox($i, _in(_div("div_dijits_0")))) etc. exist as ElementStub objects (which evaluate to true when used in while or if). To fetch the right values from the browser, they need to be used in _set, _condition or any of the Browser Action APIs.

    Regards,
    Narayan
  • KareemJKareemJ Members
    Thanks tried it and its working properly.
This discussion has been closed.