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.

_call() doesn't return variable

Cubicle.JockeyCubicle.Jockey Members
edited November 2008 in Sahi - Open Source
Hey all,

I have a javascript function:
function getHandsetReportButtonID($IMEI)
{
    //Constants Start
    var handsetIMEIIndex = 4;
    var buttonListIndex = 5;
    var reportRegex = "doGetHandsetReportsId-[0-9]*";
    var IMEIRegex = ("<div id=\"handset-list-cell-handset-imei-[0-9]*\" class=\"handset-list-cell-handset-imei\">" + $IMEI +"</div>");
    //Constants End
    
    var handSetsTable = document.getElementById('handset-list-table-body');
    if(handSetsTable)
    {
        //loop is incremented by 2 because the there is a hidden row per visiable row
        for(var index =0; index < handSetsTable.rows.length; index = (index + 2))
        {
            var columns = handSetsTable.rows[index].cells;
            
            var IMEIOfDiv = columns[handsetIMEIIndex].innerHTML.match(IMEIRegex);
            if(IMEIOfDiv)
            {
                $reportID = columns[buttonListIndex].innerHTML.match(reportRegex);
                if($reportID)
                {
                    //document.write($reportID);
                    return $reportID;
                }
                else
                {
                    document.write("Error with regex match: " + reportRegex);
                }
            }
        }
    }
}
and it gets called like so:
$reportButtonID = _call(getHandsetReportButtonID("99999990000000"));
no matter what I try the $reportButtonID is considered NULL but sahi........WHY!?!?!?!?!?!??!!? When I run it by itsself or have it document.write that return value I get the value I am looking for from the javascript funciton.

Thanks

Comments

  • StringyLowStringyLow Members
    edited November 2008
    try using:


    var $reportButtonID;

    _set($reportButtonID, getHandsetReportButtonID($IMEI));

    Sahi is particular about using _set() for assigning values to variables used in a Sahi script.
  • That did it thanks a bunch!
Sign In or Register to comment.