Please note that Sahi's development and support teams do not actively monitor this. This is more a community forum. If you are a Sahi Pro user looking for commercial support, please email support @ sahipro.com with your query.

A bug?

I wrote a function to setValue for various types of text input fileds (textbox/textarea/password) like this:
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.
Sign In or Register to comment.