NoSuchElement exception is not coming when webElement not found in a page in webdriver
java, selenium-webdriver, webdriver
Solution
Try by setting implicit timeout for finding the element
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
try {
driver.findElement(By.id("element_id"));
System.out.println("Element Found");
} catch (NoSuchElementException e) {
System.out.println("Element Not Found");
}
Problem
NoSuchElement exception is not coming when webElement not found in a page in webdriver when webelement is available in a page, all the operation done on that webelement will work, but if the webelement is not available in that page, then ideally when we do any operation on that webelement it should throw a exception. But for me no exception is coming and the test does not respond , even on debugging it does not respond at that place. Can anyone tell me y this is happening ?