Google+

SessionNotFoundException WebDriver Exception

Before understanding SessionNotFoundException, you have to first understand the below:


So, after understanding 'What is an Exception and the different types of Exceptions in Selenium WebDriver', you are now ready to understand SessionNotFoundException in a detailed and practical way.

SessionNotFoundException will occur when driver is trying to perform operations on the Web Application after the Browser is closed or when the Browser Session is not available.

Practical Example for SessionNotFoundExcpetion:

1. Open Firefox Browser and open http://www.omayo.blogspot.com as shown below:



2. Write Selenium code in such a way that you are trying to perform operations on the Web Application when the Browser Session is not available (i.e. when the browser is closed) as shown below:



3. Execute the above code and observe that 'SessionNotFoundException' WebDriver Exception will be displayed in the Eclipse IDE console as shown below:



Hence SessionNotFoundException WebDriver Exception will occur when driver is trying to perform operations on the Web Application after the Browser is closed or when the Browser Session is not available. And it is not a good idea to handle this kind of exceptions, instead we have to take measures to keep the Browser Active by modifying the code, so that the rest of the code can run only when the Browser is not closed.

No comments:

Blog Index