18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
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.
Using a string variable
Hi,
I am confused about using the following code:
1 var $default;
2
3 $default = _textbox(0).value;
4 _setValue(_textbox(0), $Max);
5 _setValue(_textbox(0), $Min);
6 _setValue(_textbox(0), $default);
My expectation is in the line 6 to receive the value of line 3 ($default). Instead of the expected value I get "_textbox(0).value".
Statement in the Playback window of line 6 is:
_setValue(_textbox(0), _textbox(0).value);
I guess I'm doing something stupid wrong. Can you help?
Regards,
Achim
I am confused about using the following code:
1 var $default;
2
3 $default = _textbox(0).value;
4 _setValue(_textbox(0), $Max);
5 _setValue(_textbox(0), $Min);
6 _setValue(_textbox(0), $default);
My expectation is in the line 6 to receive the value of line 3 ($default). Instead of the expected value I get "_textbox(0).value".
Statement in the Playback window of line 6 is:
_setValue(_textbox(0), _textbox(0).value);
I guess I'm doing something stupid wrong. Can you help?
Regards,
Achim
This discussion has been closed.
Comments
Replace line 3 with _set($default, _textbox(0).value);
Cheers
dp
Nothing stupid
Accessors of Sahi return an element stub. They are executed only on the browser when you pass it to a browser action API.
Normal example:
In your case, what you need is to evaluate _textbox(0).value on the browser and get its value.
You need to use _set in this case.
Eg.
1 var $default;
2
3 _set($default, _textbox(0).value); // _set fetches the value from the browser and sets it to $default
4 _setValue(_textbox(0), $Max);
5 _setValue(_textbox(0), $Min);
6 _setValue(_textbox(0), $default);
Hope that helps.
Regards,
Narayan
I think I understood my mistake - now everything works fine. Thanks for your help!
Regards,
Achim