Here in this tutorial we will learn about types of exceptions and how to handle exceptions in Java and Selenium scripts. Developers/testers use exception handling framework to handle an exception in selenium scripts.
When selenium script fails due to the wrong locator, then the developer should be able to understand the reason for failure and this can be achieved easily if the exception is handled properly in the program.
Below we have described the types of exceptions and the different ways how we can use exception handling framework in selenium scripts.
Exceptions are events due to which java program ends abruptly without giving expected output. Java provides a framework where a user can handle exceptions.
There are three kinds of exceptions:
The class hierarchy of exception and error:
When selenium script fails due to the wrong locator, then the developer should be able to understand the reason for failure and this can be achieved easily if the exception is handled properly in the program.
Below we have described the types of exceptions and the different ways how we can use exception handling framework in selenium scripts.
Exceptions are events due to which java program ends abruptly without giving expected output. Java provides a framework where a user can handle exceptions.
There are three kinds of exceptions:
- Checked Exception
- Unchecked Exception
- Error
The class hierarchy of exception and error: