Top Rounds
| We are Hiring! |

_set ·

This is a Browser Action API.

_set is used to fetch the value of a page dependent variable (something that is part of the browser page) and store it in a Sahi variable. You would need this to access Javascript attributes not already exposed by Sahi’s APIs.

Syntax:

_set( $variableName, value );

The parameters are:

  • $variableName: variable to assign the value to
  • value: value to assign. Note that the value should not be a javascript object which has attributes which reference itself.

Example:

If we wish to get the href of a link,

var $href;
_set($href, _link("my link").href); // store
// you may do other actions or navigate to other pages 
_assertEqual("http://sahi.co.in", $href); //use 

Note that there is no Sahi API to retrieve the href property directly. For retrieving text using _getText, _set is not required.

var $text = _getText(_link("linkId"));

Another example with a browser function:

<browser>
function getRowLength(){
  return _table("t1").rows.length
}
</browser>
var $count=0;
_set($count, getRowLength());
_alert($count);

Also look at Sahi Scripting Basics – 2




---


Top Rounds