During every automation testing processes in Selenium, you may come across many scenarios that are not common. Those are called “exceptions,” and are inevitable when you execute your test cases even with other automation testing tools such as Katalon Studio. Nevertheless, you will achieve them if you know how to handle them properly. This article will provide some better understanding of exception handling.
What are Selenium Exceptions?
An exception is known as an unusual or unprecedented event that occurs during the execution of a software program or application. It is a runtime error of an unexpected result or event which influence and disrupt usual program flow. An exception is also considered as a fault.
Classification of Selenium exceptions
Selenium exceptions are divided into two types including Checked Exceptions and Unchecked Exceptions:
- Checked Exceptions
Checked Exceptions are handled during the process of writing codes. These exceptions are handled before compiling the code, therefore, such exceptions are examined at the compile time.
- Unchecked Exceptions
These exceptions are thrown at runtime. Unchecked exceptions are more catastrophic than the compile-time exception as it causes problems while running Automation pack in headless.
Common Exceptions in Selenium WebDriver
- ConnectionClosedException: This exception takes place when there is a disconnection in the driver.
- ElementClickInterceptedException: The command could not be completed as the element receiving the events is concealing the element which was requested clicked.
- ElementNotInteractableException: This Selenium exception is thrown when an element is presented in the DOM but it is impossible to interact with such element.
- ElementNotSelectableException: This Selenium exception is thrown when an element is presented in the DOM but you can be able to select. Hence, it is impossible to interact with.
- ElementNotVisibleException: This type of Selenium exception takes place when existing elements in DOM has a feature set as hidden. In this situation, elements are there, but you can not see and interact with the WebDriver.
- ErrorHandler.UnknownServerException: Exception is used as a placeholder if the server returns an error without a stack trace.
- ErrorInResponseException: This exception is thrown when a fault has occurred on the server side. You can see it happens when interacting with the Firefox extension or the remote driver server.
- ImeActivationFailedException: This exception occurs when IME engine activation has failed.
- ImeNotAvailableException: This exception takes place when IME support is unavailable.
- InsecureCertificateException: Navigation made the user agent to hit a certificate warning, which is caused by an invalid or expired TLS certificate.
Read more exceptions at katalon.com/resources-center/blog/selenium-exceptions/
All exceptions mentioned above are the most common cases in every automation projects. Thereby, you could handle the exceptions wisely since you grasped all perspicuous explanations. We hope you will use this article as a reference for managing exceptions and optimization codes in Selenium as well as Katalon Studio.