


Get over it! Simple solutions to overcome elements in automation tests
Jul 18, 2024
2 min read
When I worked on my automation project, one of the tasks I had to overcome was handling elements that are difficult to interact with, such as alerts, pop-ups, and dropdowns.
At first, I thought maybe I didn't identify the element correctly, so I tried again by - ID, Name, Css Selector, XPath.
When that didn't help, I realized I needed to try a different approach.
So, I researched and read up on it, and eventually, I succeeded.
It was important to me to succeed on my own, without using AI.
(Don’t get me wrong,  AI is very helpful when needed, if used correctly.)
Here are a few examples from my project:
Problem: Element Not Interactable
Example: You are trying to click a button, but you get an -ElementNotInteractableException.
Solution:Â Ensure the element is visible and enabled before interacting with it.

Problem: Element Not Found
Example:Â You are trying to find an element but get a NoSuchElementException
Solution:Â Use explicit waits to allow time for the element to appear

Problem: Handling Pop-ups and Alerts
Example: You need to handle a JS alert or pop-up
Solution: Switch to the alert and insert text/accept/dismiss it

Here is the alert text box from my project, I needed to insert some text in order to move forward:

Click to watch the alert text box:
In this case I needed to wait for the pop-up to be visible and clickable in order to close it:

Click to watch the pop-up:
Problem: Handling Dropdowns
Example: You need to select an option from a dropdown menu
Solution: Use the Select class from selenium.webdriver.support.ui

This is the dropdown from my project:

So...did you get over it?