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.

var srctext = _image("SAVE CHANGES").src; why can't I

joewjordanjoewjordan Members
edited November -1 in Sahi - Open Source
if
_log(_image("SAVE CHANGES").src); Show the source path of the image

why can't I set it to a variable

var srctext = _image("save").src;

I get error TypeError: _sahi._image("SAVE CHANGES") is null

but the log function is proving both that the _image() is not null, and that _image().src returns something.

Comments

  • You need to proceed the variable with a "$".

    example:

    var $srctext = _image("save").src;
  • I am not to sure on the difference from
    var variablename
    and
    var $Variablename
    I have seen and used both methods of syntax so far in sahi

    But in this case
    var srctext = _image("SAVE CHANGES").src; <--- will just error out
    var $srctext = _image("SAVE CHANGES").src; <---will set $srctext to null

    neither of which gets me to the actual text of the source of the image

    But like I said the _log(_image("SAVE CHANGES").src); will correctly show the text of the image src=""
  • Try this to get around the setting to null issue when it is a $ var.

    var $srctext = "";
    _set($srctext, _image("SAVE CHANGES").src);
  • Thank you C.J that works for me.
  • From http://sahi.co.in/w/sahi-script-and-javascript
    Prefix a $ sign before variables which are passed to sahi functions.

    var $name = "karthik"; _setValue(_textbox("userName"), $name);
Sign In or Register to comment.