18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
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.
Validating list order solution, bug (?)
Hello. I've been using Sahi (build 2011-07-19 on Windows 7 with IE 8) for a few months now and it's been great, but I've gotten stuck on this one particular area until now (maybe).
We have several popup menus that we want to validate the visibility and order of. After searching the forums and a lot of mix and matching of the APIs, I think I've got a solution.
For this menu of links...
Item 1
Item 2
Item 3
Item 4
...I have this code...
_assertNotTrue(_isVisible(_listItem("Item 1", _under(_listItem("/.*/")))));
_assertEqual("Item 2", _getText(_listItem(0, _under(_listItem("Item 1")))));
_assertEqual("Item 3", _getText(_listItem(0, _under(_listItem("Item 2")))));
_assertEqual("Item 4", _getText(_listItem(0, _under(_listItem("Item 3")))));
_assertNotTrue(_isVisible(_listItem("/.*/", _under(_listItem("Item 4")))));
I'm assuming that the validation of the visibility is implied. In other words, if Item 3 was not there or renamed, the script would fail. Similarly, if a new/unexpected item appeared between Item 2 and Item 3, the 3rd line above would fail.
I used the 0 to identify/assert that one item appears after the other which seems to give me order validation.
To validate that there are no other items after Item 4, I've used the /.*/ wildcard and it breaks as expected if there's another item under it. However, I'm not getting the expected result for the wildcard in the first line (bug or my mistake?) which is trying to validate that Item 1 is not preceded by any other items.
If you see any holes in this logic, or have found a better way to handle non-table sort/order, please reply.
Thanks
We have several popup menus that we want to validate the visibility and order of. After searching the forums and a lot of mix and matching of the APIs, I think I've got a solution.
For this menu of links...
Item 1
Item 2
Item 3
Item 4
...I have this code...
_assertNotTrue(_isVisible(_listItem("Item 1", _under(_listItem("/.*/")))));
_assertEqual("Item 2", _getText(_listItem(0, _under(_listItem("Item 1")))));
_assertEqual("Item 3", _getText(_listItem(0, _under(_listItem("Item 2")))));
_assertEqual("Item 4", _getText(_listItem(0, _under(_listItem("Item 3")))));
_assertNotTrue(_isVisible(_listItem("/.*/", _under(_listItem("Item 4")))));
I'm assuming that the validation of the visibility is implied. In other words, if Item 3 was not there or renamed, the script would fail. Similarly, if a new/unexpected item appeared between Item 2 and Item 3, the 3rd line above would fail.
I used the 0 to identify/assert that one item appears after the other which seems to give me order validation.
To validate that there are no other items after Item 4, I've used the /.*/ wildcard and it breaks as expected if there's another item under it. However, I'm not getting the expected result for the wildcard in the first line (bug or my mistake?) which is trying to validate that Item 1 is not preceded by any other items.
If you see any holes in this logic, or have found a better way to handle non-table sort/order, please reply.
Thanks
Comments
Here is a better way which you could use:
Regards
Sumitra
Is there any logical reason that
_assertNotTrue(_isVisible(_listItem("Item 1", _under(_listItem("/.*/")))));
doesn't work for the first item, but seems to work for the last item?
In your case, _assertNotTrue() just checks if Item1 is under ANY listitem and if item1 is visible it will return true. Instead you should just verify if the element above item1 is not visible.
I have modified my earlier code:
The HTML code for the list items is:
The script for this would be:
Regards
Sumitra