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.

_set action does not always work

BstokerBstoker Members
edited November -1 in Sahi - Open Source
I've run into an odd problem where the _set command does not appear to consistently work. I've also noticed that the sahi application throws the following:

Different step: received: 1; current:2; type=INFO; failureMessage=null
Different step: received: 10; current:12; type=INFO; failureMessage=
Different step: received: 17; current:18; type=INFO; failureMessage=null

I've included a sample of the statements where you can see I'm traping the values of the variables and displaying. Notice that the value of $Pos1 does not change from the previous step.

_assertTrue("US1L009821" == "US1L009821");
_alert("" + " vs " + "US1L021164");
_setSelected(_select("ctl00\$cphMain\$ddlIDType"), "Markit ID");
_click(_textbox("ctl00\$cphMain\$txtSearchIdTxt"));
_setValue(_textbox("ctl00\$cphMain\$txtSearchIdTxt"), "US1L021164");
_click(_submit("Search"));
setServerVar('\$results', _getText(_cell(_table(0), 1, 0)));
setServerVar('\$Pos1', _getText(_cell(_table(0), 1, 1)));
_alert("US1L009821" + " vs " + "US1L021164");
_assertTrue("US1L009821" == "US1L021164");

In the sample I am resetting $Pos1 to "" for debugging. While I'm watching the script perform the contents of the web page in the last step is not the value that which the setServerVar command is setting. I've restarted sahi twice.

Comments

  • narayannarayan Administrators
    Bstoker,

    Can you show the script too?

    Regards,
    Narayan
  • BstokerBstoker Members
    // Get the DB instance
    var db = _getDB("sun.jdbc.odbc.JdbcOdbcDriver","jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=c:\\temp\\MEI.xls;readOnly=false","","");

    // Run a select
    $rs = db.select("select * from [Sheet1$]");


    // loop through spreadsheet and search IDs
    for (var $i=0; $i < $rs.length; $i++){
    var $row = $rs[$i];
    var $mei = $row["Id"];
    //_alert($mei);
    IDSearch($mei);}


    // ID Search



    function IDSearch($mei)
    {
    var $Pos1 = "";

    //_alert($Pos1 + " vs " + $mei);
    _setSelected(_select("ctl00\$cphMain\$ddlIDType"), "ID");
    _click(_textbox("ctl00\$cphMain\$txtSearchIdTxt"));
    _setValue(_textbox("ctl00\$cphMain\$txtSearchIdTxt"), $mei);
    _click(_submit("Search"));
    _wait(1000);
    _set($results, _getText(_cell(_table(0), 1, 0)));

    if ( $results != "no results"){

    //_wait(500);
    //_set($Pos1, _getText(_cell(_table(0), 1, 1)));
    _set($Pos1, _getText(top.document.getElementsByTagName('table')[0].rows[1].cells[1]));


    _alert($Pos1 + " vs " + $mei);
    _assertTrue($Pos1 == $mei);

    var $sqlString = "update [Sheet1$] set Status = 'Pass' where Id ='" + $mei +"'";

    //update spreadsheet
    if ($Pos1 == $mei){db.update($sqlString);
    }

    } else {
    var $sqlString = "update [Sheet1$] set Status = 'Fail' where Id ='" + $mei +"'";
    db.update($sqlString);
    }
    }
  • BstokerBstoker Members
    I figured out the problem. It was a timing issue. I believe the script was reading the cell before it had a chance to refresh. Sometimes the results are real quick while others took a few seconds. I added the following to the code to the function and the problem of the mismatched IDs went away.

    if ($pos1 != $mei){
    _wait(3500);
    _set($pos1, _getText(_cell(_table(0), 1, 1)));
    }

    I am however still getting a lot of the Different Step error messages and over a long period the scripts finally just stop working. For example see below.

    Different step: received: 2496; current:2497; type=INFO; failureMessage=
    Different step: received: 3960; current:3961; type=INFO; failureMessage=null
    Different step: received: 4770; current:4771; type=INFO; failureMessage=null
    Different step: received: 6472; current:6474; type=INFO; failureMessage=
    Different step: received: 6771; current:6773; type=INFO; failureMessage=
    Different step: received: 6773; current:6774; type=INFO; failureMessage=
    Different step: received: 6776; current:6778; type=INFO; failureMessage=
    60
    60
    Rhino lib:### Step did not return in 300 seconds.
  • narayannarayan Administrators
    Generally "Different step" does not cause any problem. It is because of some race condition on the browser due to frames/iframes/popup windows. I will have a look at it to see if it is incorrect.

    "Step did not return in 300 seconds" is more important. It means that the browser has frozen or due to some other reason, a step did not complete, and the browser was closed or killed by Sahi eventually. Does this error always occur after those "Different step" errors? They may be related.

    Regards,
    Narayan
Sign In or Register to comment.