An Exception is an event, which occurs during the execution of a program that disrupts the normal flow of the program's instructions or in simple words, any issue which makes your test case stop in between the execution.
When exception occurs, the normal flow of program halts & an exception object is created. The program then tries to find someone that can handle the raised exception.
The exception object contains a lot of debugging information such as method hierarchy, line number where the exception occurred, type of exception etc. The process of creating the exception object and handing it over to run-time environment is called "throwing the exception"
Common Exceptions in Selenium WebDriver :
There is a complete list of Exceptions in Selenium WebDriver mentioned in the Selenium Doc which you may or may not encounter in course of your testing. Hence in this article we will focus on some most common exceptions in Selenium WebDriver,
Although an element is present in the DOM, it is not visible (cannot be interacted with). E.g. Hidden Elements â€“ defined in HTML using type=â€?hiddenâ€?.
Although an element is present in the DOM, it may be disabled (cannot be clicked/selected).
Selector used to find an element does not return a WebElement. Say XPath expression is used which is either syntactically invalid or does not select WebElement.
kotlin selenium is unable to identify the elements during run time, i.e. FindBy method canâ€™t find the element.
selenium is switching to an invalid frame, which is not available.
Selenium kotlin is switching to an invalid alert, which is not available.
When user tries to switch to a window which is not available.
The referenced element is no longer present on the DOM page (reference to an element is now Stale). E.g. The Element belongs to a different frame than the current one OR the user has navigated away to another page.
The selenium kotlin is trying to perform the action immediately after 'quitting' the browser.
The command did not complete in enough time. E.g. the element didnâ€™t display in the specified time. Encountered when working with waits.
The kotlin selenium client is performing the action immediately after 'closing' the browser.
Article is written by Pavan (a) KarthiQ. Well, I am serving notice period in an MNC, Bangalore. I thought to enrich every person knowledge a little, I always have a feeling, when we teach something, we will learn more than what you know.
Knowledge is the only thing that doubles when you spend it.
I have also created the reporter for Protractor Jasmine. Use for your projects without any hesitation