Sahi Pro - Generic Accessor APIs


_activeElement

Since Sahi Pro: 4.0
Since Sahi OS: 4.3

_activeElement()

Arguments
None

Details

Returns the element which is in focus.
May be used to verify if the specific element is the one in focus.
Eg
_assertEqual(_texbox("user"), _activeElement());

_byId

Since Sahi Pro: 3.5
Since Sahi OS: 2

_byId($id)

Arguments
$idstring id of element

Details

Used to find elements solely by id without using its tagName information.
<div id="errormsg">Error</div>
_byId("errormsg") // points to the above tag. Note that the tagName "div" is not used here.

_byText

Since Sahi Pro: 3.5
Since Sahi OS: 2

_byText($text, $tagName)

Arguments
$textstring text of element
$tagNamestring tagName of element which has this text. eg. "DIV"

Details

Used to find element by text and tagName
<div id="errormsg">some text</div>
_byText("some text", "DIV") // points to the above tag.
danger DEPRECATED:
Use _div("some text") or more specifically _div({sahiText:"some text"}) instead

_byClassName

Since Sahi Pro: 3.5
Since Sahi OS: 3

_byClassName($className, $tagName[, $relations ...])

Arguments
$classNamestring className of element
$tagNamestring tagName of element which has this text. eg. "DIV"
$relations ...relation optional DOM or Positional Relations

Details

Finds element by className with given tagName and constrained by given relations
<div class="bigfont">Some text</div>
_byClassName("bigfont", "DIV")

danger DEPRECATED:
Use _div("bigfont") or more specifically _div({className:"bigfont"}) instead

_byXPath

Since Sahi Pro: 3.5
Since Sahi OS: 3

_byXPath($xpath)

Arguments
$xpathstring XPath of element

Details

Eg.
_byXPath("//table[3]//tr[1]/td[2]")
_byXPath("//tr[1]/td[2]")
This is a convenience method for people moving from Selenium or other tools to Sahi.
info XPaths are natively enabled on Firefox.
For browsers like Internet Explorer which do not have support for XPath use Javascript-XPath.

For browsers without XPath support, use Javascript-XPath: (http://coderepos.org/share/wiki/JavaScript-XPath)
Copy the contents from http://svn.coderepos.org/share/lang/javascript/javascript-xpath/trunk/release/javascript-xpath-latest.js and save the file as sahi/htdocs/spr/ext/javascript-xpath/javascript-xpath.js

This file is under its own MIT license and is not part of Sahi's code base

_accessor

Since Sahi Pro: 3.5
Since Sahi OS: 2

_accessor($string)

Arguments
$stringstring String to eval

Details

This API just evaluates the string and returns a dom object. Eg. _accessor("document.formName.elementName").
This API is not very useful.

_bySeleniumLocator

Since Sahi Pro: 3.5
Since Sahi OS: 3

_bySeleniumLocator($locator)

Arguments
$locatorstring selenium locator

Details

Allows identification of elements using some Selenium locators. Use only while migrating from Selenium to Sahi.