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.

Javascript translation error

xumixxumix Members
edited June 2010 in Sahi - Open Source
function GetJsId($id)
{
    return $id.replace(/-/g, "");
}

var $ItemId = GetJsId(_hidden("Id").value);
_setValue(_textbox("DocEntity_form_" + $ItemId + "_BaseClass"), "ref");


Gets converted during test execution into this:
_setValue(_textbox("DocEntity_form_" + _hidden("Id").value.replace(/-\//, "") + "_BaseClass"), "ref");
which obviously doesn't work

Comments

  • xumixxumix Members
    Now I tried
    <browser>
    function GetJsId(id)
    {
        return id.replace(/-/g, "");
    }
    </browser>
    
    And it says JSERROR
    ReferenceError: "GetJsId" is not defined. at 07.06.2010 18:25:25
  • narayannarayan Administrators
    Hi Xumix,

    If you wish to work with values from the browser, use _set. In your case:
    
    function GetJsId($id)
    {
        return $id.replace(/-/g, "");
    }
    
    var $ItemIdWithHyphen;
    _set($ItemIdWithHyphen, _hidden("Id").value); // first fetch from browser to proxy
    
    
    var $ItemId = GetJsId($ItemIdWithHyphen); // remove hyphen
    
    _setValue(_textbox("DocEntity_form_" + $ItemId + "_BaseClass"), "ref");
    
    
  • xumixxumix Members
    edited June 2010
    Thanks!
    BTW I've found the solution just 10 minutes before your post:)
    PPS whats the purpose of <browser> tags?
Sign In or Register to comment.