Pages

Showing posts with label NoSuchElementException. Show all posts
Showing posts with label NoSuchElementException. Show all posts

Sunday, 4 March 2012

How can I check the presence of WebElement on page?

We can check the presence of WebElement on page by implementing custom isElementPresent method as below:


	protected boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}

This method will return true, if the WebElement with ‘by’ available otherwise returns false.