I have a webpage which i'm trying to automate using selenium webdriver...will give a short description abt d webpage, when i enter a valid id in the inputbox and clicks on search button..i will get the results of the input provided...if i give an invalid input..it will give "No records Found!" message..i want to handle both the cases by writing isElementPresent(By by) method...can anyone help on this ?? how to write a method including syntax...or anyone please post the sample method with a code example...sooner response is much appreciated !!
Asked
Active
Viewed 73 times
-1
-
I am afraid but this is not a good place to ask this kind of question – Saifur Mar 18 '15 at 13:26
-
http://stackoverflow.com/questions/7991522/selenium-webdriver-test-if-element-is-present – DRVaya Mar 18 '15 at 13:33
1 Answers
1
I put together a code snippet in another question very recently that does this:
https://stackoverflow.com/a/29149283/4611801
public boolean elementExists(By selector)
{
try
{
driver.findElement(selector)
return true;
}
catch(NoSuchElementException e)
{
return false;
}
}