18 January 2026:


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.

Introducing _in, _parentNode, _parentCell, _parentRow and _parentTable

narayannarayan Administrators
edited November -1 in Sahi - Open Source
Folks,

From the nightly unstable release 2009-03-23 (https://sourceforge.net/project/showfiles.php?group_id=151639&package_id=309861&release_id=670229), a few new features have been added to make life easier while navigating tables and cells.

To access the cell in which a link lies, you can do
_parentCell(_link("inside link"))
To access the parent row, use
_parentRow(_cell("cellId"))
Like wise for parent table
_parentTable(_link("inside link"))
You can pass any contained element in the cell, row or table.

Another useful thing is if you have a hierarchy like this: link -> table1 -> table2 and you wish to access the outer table "table2", you can do
_parentTable(_link("inside link"), 2); The second parameter denotes the level.
_parentTable(_link("inside link"), 2) is equivalent to _parentTable(_parentTable(_link("inside link")));
Same with _parentCell and _parentRow
If you wish to get to a parentNode of a given tagName you can use,
_parentNode(el, tagName, level);
eg. _parentRow(el, 2) == _parentNode(el, "TR", 2);


A cell can now be identified just by the text in it.
_cell("text in cell")
But even more useful is _in.

Suppose you have a table which looks like this
username1  |  link: delete  |  link: edit  |  checkbox: isActive
username2  |  link: delete  |  link: edit  |  checkbox: isActive
To get the second "delete" link, you can do
_link("delete", _in(_parentRow(_cell("username2"))));
Previously you would have had to do _link("delete[1]"), where [1] is dependent on the order of rows

To get the second isActive checkbox, you can do
_checkbox("isActive", _in(_parentRow(_cell("username2"))));
This helps your Sahi scripts be independent of order of rows in the tables.

Similary you can do:
_textbox(identifier, inElement);
_textarea(identifier, inElement);
_password(identifier, inElement);
_checkbox(identifier, inElement);
_radio(identifier, inElement);
_image(identifier, inElement);
_imageSubmitButton(identifier, inElement);
_link(identifier, inElement);
_cell(identifier, inElement);
_spandiv(identifier, inElement);

inElement = _in(element where you wish to look)

Another feature added is identification of images via the image file name.
_image("add.gif")
Please have a look at this build and share your thoughts.

Regards,
Narayan

Comments

  • Thats Great Narayan!
    Right now I was navigating through my table elements using DOM. The new APIs will indeed make our lives easier :)
    Can I straight away copy these APIs to older sahi version that I am using now?

    Thanks and Regards,
    Pankaj.
Sign In or Register to comment.