Selenium WebDriver Exceptions
Selenium Webdriver exceptions will discuss about what kind of exception we will get in selenium webdriver while executing the automation scripts. An exception is an infallible statement; it will always tell you why something has gone wrong in the code. It may not always be easy to understand the exception, but it does always tell the information about the what is wrong in the code.
One of the good things in selenium is while looking into the exception we will come to know what went wrong as the exception names will give some what clear picture for the error which we will face.
Below are some of the Exceptions which we will see while automating the applications:
Now we will see briefly about these exceptions:
This is the most and frequent facing exception. You will definitely find this kind of exception while automating the application. The reason for this exception is, the element you are trying to find does not exist.
This is also most and frequent facing exception. In modern applications people are using iFrames very frequently. When you try to find an iFrame on application and it is not exist in the application then code will throw NoSuchFrameException.
This is also very similar to the previous exception. A Window is a browser which is opened by the webdriver or child window(i.e.another browser opened from the parent browser). When you try find a Window and that is not available at present, then the code will throw NoSuchWindowException.
This is also most and very frequent facing exception. This ElementNotVisibleException tells you that the WebElement that you are trying to interact with is not visible to the user.
This exception you can not find very frequently. When you try to interact with any element then an unexpected popup will come but we are not sure why and what it is. An InvalidElementStateException is thrown when the WebElement that you are trying to interact with is not in a state that would allow you to perform the action that you would like to perform.
Sometimes you will face this type of Exception. As we know that selenium sends commands to the browser to execute and get the response back. Sometimes we will not get the response from the browser then we will get UnreachableBrowserException.
You will not get this kind of exception frequently. But while you executing your tests and something will go wrong and will lose connection with the browser instance that you are driving. Then you will get SessionNotFoundException.
These are the most frequently exceptions we will face while automating any kind of application.
Please watch the YouTube video for this blog for better understanding.