Im filling a registration form. After filling all the fields I click on register then I get a message which is hidden initially. So I'm trying since very long to locate that particular element.
But I'm not able to locate that element due to which that particular error is never caught and I cannot proceed.
Need you input guys. I've tried isDisplayed(), isEnabled() etc. None of them work. I've even worked on writing custom methods to handle this but that too isn't able to handle.
//isElementPresent is custom method written by me
//Appointment.PhoneNoMatch is the locator which I've stored in objectrepository
boolean phoneError = isElementPresent(Appointment.PhoneNoMatch);
if (phoneError==true)
{
System.out.println("Phone No already exist");
break;
}
else
{
//Rest of the execution
}
public boolean isElementPresent(By by) throws Throwable {
try {
List<WebElement> ele = driver.findElements(by);
if (ele.size() > 0) {
return true;
}
else
{
return false;
}
}
catch (Exception e)
{
System.out.println(e.getMessage());
return false;
}
}