While completing a registration form, I encounter a hidden message after clicking on the register button. Struggling to locate this elusive element has been an ongoing challenge for me.
Unfortunately, my attempts to find the element have been unsuccessful, preventing me from catching the error and progressing with the registration process.
I could really use some input on this issue. I've tried using methods like isDisplayed() and isEnabled(), but none of them seem to work. Even creating custom methods to handle the situation hasn't resolved the problem.
//isElementPresent is a custom method I've created
//Appointment.PhoneNoMatch is the locator stored in objectrepository
boolean phoneError = isElementPresent(Appointment.PhoneNoMatch);
if (phoneError == true)
{
System.out.println("Phone number already exists");
break;
}
else
{
//Continue with the remaining 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;
}
}