Selenium With Java

1Exception Handling in Selenium and Java
     1.1. Exceptions in Java
     1.2. Exceptions in Selenium and how to handle them
2. Next topic






*************************************************************************

1.2. Exception Handling in Java:


In Java, an exception is an event that disrupts the normal flow of the program. It is
 an object which is thrown at runtime.

Exception Handling is a mechanism to handle runtime errors.

The core advantage of exception handling is to maintain the normal flow of
 the applicationAn exception normally disrupts the normal flow of the
 application; that is why we need to handle exceptions.


Hierarchy of Java Exception classes

The java.lang.Throwable class is the root class of Java Exception hierarchy inherited
 by two  subclasses:
 Exception and Error. The hierarchy of Java Exception classes is given below:





Types of Java Exceptions

There are mainly two types of exceptions: checked and unchecked. An error is
 considered as the unchecked exception.
       1.Checked Exception.
2.Unchecked Exception.
3. Error

Difference between Checked and Unchecked Exceptions

1) Checked Exception

The classes that directly inherit the Throwable class except RuntimeException and
 Error are known as checked exceptions. For example, IOException, SQLException,
 etc. Checked exceptions are checked at compile-time.

2) Unchecked Exception

The classes that inherit the RuntimeException are known as unchecked exceptions.
 For example, ArithmeticException, NullPointerException,
 ArrayIndexOutOfBoundsException, etc. Unchecked exceptions are not checked at
 compile-time, but they are checked at runtime.

3) Error

Error is irrecoverable. Some example of errors are OutOfMemoryError,
 VirtualMachineError, AssertionError etc.
 








No comments:

Post a Comment