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.
searching texts in the current page
Hi,
Does sahi have a function which searches texts in the page?
for example if you only have this simple HTML code:
<html>
<body>
<h3>My Information</h3>
<table>
<tr><td>Name</td><td>numner</td></tr>
<tr><td>my name here</td><td>000000000</td></tr>
</table>
<b>Another Information</b>
</body>
</table>
</html>
I can get the values/texts of the table columns, but I don't know how to get sahi to search for the texts "My Information" and "Another Information".
Is this possible?
Thanks!
Does sahi have a function which searches texts in the page?
for example if you only have this simple HTML code:
<html>
<body>
<h3>My Information</h3>
<table>
<tr><td>Name</td><td>numner</td></tr>
<tr><td>my name here</td><td>000000000</td></tr>
</table>
<b>Another Information</b>
</body>
</table>
</html>
I can get the values/texts of the table columns, but I don't know how to get sahi to search for the texts "My Information" and "Another Information".
Is this possible?
Thanks!
Comments
_assertTrue(_containsText(document.body, "My Information"));
public boolean assertDivTextEquals(String identifier, String text){
return browser.div(identifier).getText().equals(text);
}
public boolean assertCellExists(String identifier){
return browser.cell(identifier).exists();
}
public boolean assertCellIsVisible(String identifier){
return browser.cell(identifier).isVisible();
}
...and so on.
Ideally, it would be something like this, with "text" being set to 'Error' or 'Exception':
public boolean assertTextNotVisible(String text){
return !document.body.containsText(text);
}
Unfortunately, I am not able to find a browser object that represents the 'document.body' that is available in the Sahi script, like you mentioned previously. I don't know if it makes a difference, but my class is not extending the junit TestCase as the example java project does. Instead it is extending a FitNesse Sequence fixture, which is used to execute the test.(necessary for running from within FitNesse).
Any ideas?
browser.accessor("document.body").containsHTML()
I think I can go ahead and use this:
public boolean assertTextNotVisible(String text){
return !browser.accessor("document.body").containsText(text);
}
I will give it a shot!