Hi All,
I'm having an issue in web driver while using isDisplayed() method.
I need to check for a dynamic object existence. If the object exists, then I need to do some actions and if it doesn't exist, I need to perfrom some other actions.
When I used the method isDisplayed() in if condition, if the object is really displayed, then it is working fine. If the object doesn't exists on the screen, then instead of returning false it is throwing an exception.
Can anyone suggest be any other best way to handle this situation?
Sample Code:
if(driver.findElement(By.id(expID)).isDisplayed()) //I've tried with isEnabled as well but it is not working.
{
driver.findElement(By.id(expID)).click();
Thread.sleep(5000);
}
else
{
//Do other actions
}
Many Thanks in advance.