Tuesday, December 3, 2013

How to verify text is present in the WebPage without locator?

Sometime there is testcase need to be verify whether text is present in the webpage without using any locators.

Script snippet to verify text is present in the Page.

Here we are using inbuilt selenium API getPageSource with contains method.GetPageSource copy hole content of view source data.
public boolean isTextPresent(String text){
if (driver.getPageSource().contains(text)) {
return true;
}
else
return false;

}

No comments:

Post a Comment