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.
A bug?
I wrote a function to setValue for various types of text input fileds (textbox/textarea/password) like this:
And there is a page with a table like this:
However when I use
I added _highlight() after the $theCell and $textbox is assigned values, and found it correctly failed when trying to _setValue() to the non-exists _textbox(0, _rightOf(_cell("Cell1"))). But I don't know why it can enter this branch to assign such value to $textbox.
The function works perfectly in the Controller, and, in my script, only this field was wrongly recognized, all other fields were OK. So I'm afraid it's a bug of Sahi. Thanks for your attention.
function setValue($label, $value) {
var $textbox = null;
// identify directly
if (_exists(_textbox($label))) {
$textbox = _textbox($label);
} else if (_exists(_textarea($label))) {
$textbox = _textarea($label);
} else if (_exists(_password($label))) {
$textbox = _password($label);
} else if (_exists(_label($label))) {
var $theLabel = _label($label);
// via label
if (_exists(_textbox(0, _rightOf($theLabel)))) {
$textbox = _textbox(0, _rightOf($theLabel));
} else if (_exists(_textarea(0, _rightOf($theLabel)))) {
$textbox = _textarea(0, _rightOf($theLabel));
} else if (_exists(_password(0, _rightOf($theLabel)))) {
$textbox = _password(0, _rightOf($theLabel));
}
} else if (_exists(_cell($label))) {
var $theCell = _cell($label);
// via cell
if (_exists(_textbox(0, _rightOf($theCell)))) {
$textbox = _textbox(0, _rightOf($theCell));
} else if (_exists(_textarea(0, _rightOf($theCell)))) {
$textbox = _textarea(0, _rightOf($theCell));
} else if (_exists(_password(0, _rightOf($theCell)))) {
$textbox = _password(0, _rightOf($theCell));
}
}
if ($textbox) {
_setValue($textbox, $value);
} else {
_fail("Textbox not found: " + $label);
}
}
And there is a page with a table like this:
| Cell1 | textarea |
| Cell2 | textbox |
However when I use
setValue("Cell1", "My value for textarea");
in my script, it actually sets value to the textbox right of Cell2.I added _highlight() after the $theCell and $textbox is assigned values, and found it correctly failed when trying to _setValue() to the non-exists _textbox(0, _rightOf(_cell("Cell1"))). But I don't know why it can enter this branch to assign such value to $textbox.
The function works perfectly in the Controller, and, in my script, only this field was wrongly recognized, all other fields were OK. So I'm afraid it's a bug of Sahi. Thanks for your attention.