catch’ will use the respective Class which is required to handle the Exception. The method of handling the exception is known as Exceptional Handling.Surround the Java Statement which is throwing the Exception using ‘try … catch’ block as shown in the below screen-shot: In the above program, if we want to continue the execution of the Java program, even after the exception occurs, we have to handle it. From the output, its very clear that the Program execution stopped due to ArithmeticException and the last statement in the above program didn’t get executed:Įxample for Handling an Exception in Java: The below output will be displayed in the Eclipse IDE console. Read the comments in the below Java program code: Statement3 //Exception occurred at this 3rd line 4th and 5th in our program wont be executed. Error: When a scenario becomes fatal and the software is unable to recoverĮxample for Exception:Lets say, we have 5 lines in our Program as shown below and if an exception occurs at 3rd line, the program execution will stop and the remaining lines i.e.During compilation, the compiler ignores. Unchecked Exception: A compiler does not need handling of unchecked exceptions.Checked Exception: Checked exceptions are handled during compile time, and if they are not caught and handled during compile time, they cause a compilation problem.There are three kinds of exceptions in Selenium and Java: On the occurrence of a certain exception, you may wish to do a set of actions. One of the primary goals of exception handling is to prevent this break and keep the application running. What is an Exception ?Exception is a problem which occurs during the execution of the program and when an Exception occurs the program execution will stop and the rest of the code in the program will not be executed.Įxceptions must be handled because they disrupt the usual flow of a program's execution. The below diagram depicts the different types of Exceptions that we commonly face while working with Selenium WebDriver:īefore understanding the different types of Exceptions which we may face while working with Selenium WebDriver, first I will explain the term Exception. Developers and Testers use exception handling framework to handle an exception in selenium scripts.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |