difference between ElementNotFound and NoSUCHELEMENTEXCEPTION

42 views
Skip to first unread message

Ram Niwas Sahu

unread,
Apr 18, 2017, 6:12:06 PM4/18/17
to webd...@googlegroups.com

I am confused in following Error , can anyone clerify this

difference between ElementNotFound and NoSUCHELEMENTEXCEPTION




darrell grainger

unread,
Apr 19, 2017, 8:49:32 AM4/19/17
to webdriver
If you look at http://seleniumhq.github.io/selenium/docs/api/java/index.html you can see the JavaDocs for Selenium. There is a NoSuchElementExcpetion but there is no ElementNotFound. I'm not sure if you are getting a message which says "Element Not Found" or are you asking about the different between NoSuchElementException and NotFoundException?

If you are asking what is the difference when Selenium throws a NoSuchElementException and when it prints the message "element not found" then the various implementations of findElement() will sometimes throw a generic SeleniumException with the message "element not found". Often because you have a bad locator or the bindings cannot figure out how to find the element. In these cases it will actually print something more like "element %s not found" where %s is replaced with the locator you attempted to use. If the findElement() implementation fails with NoSuchElementException then it is more likely the locator is valid and the element just does not exist, at that moment.

If you are asking when does Selenium throw a NoSuchElementException versus a NotFoundException, it never throws a NotFoundException. The NotFoundException is a parent class of NoSuchElementException. This is just good Java practice.
Reply all
Reply to author
Forward
0 new messages