Just like Selenium webdriver provides various Exception handling for Java, is there any way we can achieve same using Protractor.
If we want to handle element not found exception, then what is the best way to do it using Protractor?
Answer to this question is now in Protractor's FAQ
WebDriver throws errors when commands cannot be completed - e.g. not being able to click on an element which is obscured by another element. If you need to retry these actions, try using webdriverjs-retry. If you would just like to catch the error, do so like this
Adapted to your question:
elm.isPresent().then(function(present) {
/* no webdriver js errors here */}
if (present) {
/* element exists */
} else {
/* element doesn't exist */
}
, function(err) {
/* error handling here, i.e. element doesn't if got ElementNotFound
but, eventually and less likely, other issues will fall in here too like
NoSuchWindowsError or ElementStaleError etc...
*/
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With