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.
How to add more conditions in an assertEquals statement
Dear All,
I need to check whether a value is displayed in a table ,using an assert statement .I wrote an assert statement like
_assertEqual("Expected Value", _getText(_cell(0,_near(_span("Reference Value"),
_under("my col name")),_table("my Table Name"))));
This assert does not throw any error , now why i am using the _table("my Table Name") statement is because the web page may contain multiple tables with similar values.
Now the problem with the above assert is that once "Expected Value", _getText(_cell(0,_near(_span("Reference Value"),
_under("my col name")) is true , sahi is not checking whether the expected text is in that table also.When i gave another name for the table name, sahi returned true.
ie
_assertEqual("Expected Value", _getText(_cell(0,_near(_span("Reference Value"),
_under("my col name")),_table("new my Table Name"))));
also gave result as true
how to proceed in these kind of situation ??
thank you
mg
I need to check whether a value is displayed in a table ,using an assert statement .I wrote an assert statement like
_assertEqual("Expected Value", _getText(_cell(0,_near(_span("Reference Value"),
_under("my col name")),_table("my Table Name"))));
This assert does not throw any error , now why i am using the _table("my Table Name") statement is because the web page may contain multiple tables with similar values.
Now the problem with the above assert is that once "Expected Value", _getText(_cell(0,_near(_span("Reference Value"),
_under("my col name")) is true , sahi is not checking whether the expected text is in that table also.When i gave another name for the table name, sahi returned true.
ie
_assertEqual("Expected Value", _getText(_cell(0,_near(_span("Reference Value"),
_under("my col name")),_table("new my Table Name"))));
also gave result as true
how to proceed in these kind of situation ??
thank you
mg
Comments
_assertTrue(_getText(_cell(0,_near(_span("Reference Value"),
_under("my col name"))=="Expected Value" && _exists(_cell("Expected Value"), _in(_table("My table")));
this evals first if the cell exists in relation to span and col, then if the cell exists in the table.
Does this solve you issue?
That statement did not work , but that idea works
_assertTrue(_getText(_cell(1,_near(_span("reference value")) ,
_under("my column name")))=="value to assert" && _assertContainsText("value to assert",
_table("my table name")));
this seems to work..I hope sahi will provide a simple function to do this.
i have another observation
in the statement
_getText(_cell(0,_near(_span("reference value")) ,_under("Column name")))
what is the point in using the statement _under("column name") , whether i use it or not, the result depend on the value 0 or any other number i give in _getText(_cell(0,_near..
my question is if i specifically need the value under a column how the _getText statement should be modified
thank you globalworming, thanks for the support.
(some people here get stuck when you don't post them 100% valide code...)
if you need to verify, that the cell is in a specific column, you could have a look at http://sahi.co.in/w/_cell
with _assertExists(_cell(_table(“my table”), “my row”, “my column”)) you may get better results.
Regards
Wormi
Thanks for the reply..._cell() method is good ..but i cant use it since for a dynamic table finding in which row my data is populated ...... is difficult
thanks again
mg