Rumen
Rumen

Reputation: 137

Sahi Script, using variable in _assertEqual

I want to put variable to check if is Equal some text in the page, but in this way - doens't work:

function check($value) {

_assertEqual($value, " - VERSION", _getText(_heading1($value, " - VERSION")));
_click(_link("Edit[1]"));
}
check ("HELP")

The result:

_assertEqual("HELP", " - VERSION", _getText(_heading1("HELP", " - VERSION"))); Error: The parameter passed to _getText was not found on the browser at check (scripts/check.sah:3) at 2015-1-28 11:53:29


So, if I do in this way, it's works:

function check($value) {
_assertEqual("HELP - VERSION", _getText(_heading1("HELP - VERSION")));
_click(_link("Edit[1]"));
}
check ("HELP")

How to put this variable to works correctly?

Upvotes: 1

Views: 594

Answers (2)

Palash Jain
Palash Jain

Reputation: 36

Rumen, the following is incorrect.

_heading1($value, " - VERSION")

A single string parameter has to be passed to _heading1. In your case, joining $value and " - VERSION" will work.

_heading1($value + " - VERSION")

The above change is what you need. So, your final function will look like this:

function check($value) {
_assertEqual("HELP - VERSION", _getText(_heading1($value + " - VERSION")));
_click(_link("Edit[1]"));
}
check ("HELP")

Upvotes: 0

Sreekanth
Sreekanth

Reputation: 378

Instead of _getText, try _set

for example:

  var $helpVersion;
  _set($helpVersion, _heading1("HELP - VERSION").textContent);
  _assertEqual("HELP - VERSION", $helpVersion);    

Upvotes: 1

Related Questions