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 returning a variable with double quotes

philliplphillipl Members
edited November -1 in Sahi - Open Source
_set($ID, _getCellText(top.document.getElementById('ctl00_c_general_lblItemID')));

The above code is assigning a number enclosed with double quotes (e.g. "100" instead of just 100).

I am trying to call the variable $ID in a popup window:

_popup("Item [$ID]")._assert....

However the test is returning a failure as it is looking for "Item ["25"]", where it is supposed to be looking for "Item [25]".

Is there any way to get rid of these double quotes?

Comments

  • Hi,

    You have to lookout for a way to get the numeric value. Try this:

    _set($ID, _getCellText(top.document.getElementById('ctl00_c_general_lblItemID')).match(/\d*/);

    _popup("Item [" + $ID + "]")._assert....

    Try if this works.

    Regards,
    Pankaj.
  • narayannarayan Administrators
    _popup("Item [" + $ID + "]") is the correct way.

    Don't use _popup("Item [$ID]"). It may work, but not recommended.
Sign In or Register to comment.