Top Coding Challenges faced in Selenium

Posted by

As selenium automation testing professional, have you faced any challenges? Here are some of the top coding challenges faced in Selenium.

Selenium WebDriver is the most popular and well-known automation tool used by various teams across organizations around the world.

It supports all operating systems, web browsers, development languages, etc.

But along with advantages, every tool has some limitations.

Selenium WebDriver also has few limitations which most of the testers come across in their day-to-day work.

This blog highlights the Selenium WebDriver challenges faced by the tester and also provides a potential solution to fix them.

Pop-up Windows

Generally, in any application, you will find random pop-ups being generated depending on the actions performed by the user. But if these pop-ups are not handled properly it would cause InterruptedException or NoAlertFoundException exceptions which would fail the Selenium script.

So how to get rid of these exceptions?

  1. In order to get rid of InterruptedException exception, we have to import a Selenium WebDriver package Alert which handles alerts. The Alert interface contains various methods like void accept(), void dismiss(), void getText() and void sendKeys (String args0).

The above methods are used to click OK button, Cancel button, fetching the text and sending any value to a field.

  • In order to get rid of NoAlertFoundException exception, we have to import a Selenium WebDriver package Wait which would wait for the alert popup to appear. Sometimes, the WebDriver runs so quickly that it expects a popup window before opened by the browser.

Hence, it is necessary to use wait until(ExpectedConditions.alertIsPresent()), an explicit wait command which waits explicitly for the browser to display a popup window.

Dynamically changing Web Elements

What are ‘Dynamically changing Web Elements’?

Dynamic Web Elements are the elements whose ID’s, ClassName are not fixed and keeps on changing when you reload the page of the application. Hence they cannot be handled simply by a locator.

So, when you run the Selenium script it would fail to detect the web element and give NoSuchElementException exception.

How to get rid of the exception?

  1. Relative Xpath with Starting Text: Suppose you want to click a button having id as:

“Techcanvass_123” which changes to “Techcanvass_147” or “Techcanvass_852” etc. on every refresh of the application. So how to automate such a dynamically changing value of a web element.

You can use ‘starts-with’ function to fetch the web element as shown below,


  • Relative XPath with Text Contains: There are can few instances where an id or class name of a web element contains dynamically changing values both at the start and at the end.

For example, If you want to click a button having id “123_Techcanvass_147” which changes to “852_Techcanvass_963” or “789_Techcanvass_456” etc. on every refresh of the application. So how to automate such dynamically changing values of a web element.

You can use ‘contains’ function to fetch the web element as shown below,

//button[@contains (@id,’_Techcanvass_’)

Sync / Timeout issues

There would have been many occurrences when there is no change in code from the development team but still, your automation script doesn’t run successfully all the time.

Hence, the success ratio of your automation script is not 100%.

One of the major reasons could be the slowness of the application which fails the script since the expected web element is not visible due to timeout or sync issues of web driver.

For example, you have handled in your script that a particular button should be clickable after certain actions performed by the user BUT…

…due to the slowness of the application the button takes time to become clickable.

This might cause your script to fail.

Another example can be of a pop-up window which should appear after certain condition which is  handled in your script but, due to slowness the application the alert window takes time to be visible which might fail your script.

In order to reduce our script failure ratio and to automation the script smartly, it is always advisable to :

  1. First, verify the existence of the web element
  2. And then, perform any action on that element.

Due to the slowness of the application, you can use elementToBeClickable, alertIsPresent, presenceOfElementLocated, visibilityOfElementLocated, etc. functions to first detect the web element and then perform any action.

Limited Testing

We all know that Selenium WebDriver is used to test any Web Based Application on any browser and on any operating system.

But, what if we want to test Desktop Based Applications or Mobile Based Applications using Selenium WebDriver?

Selenium WebDriver cannot be used to test Desktop Based Applications.

For Mobile Based Applications, we can use Appium from Selenium WebDriver’s protocol to test all native, hybrid and mobile web apps for iOS and Android devices.

Scalability and Framework Enhancement

In any Development Methodology, the application code keeps on increasing and changing as per the business requirements.

Hence, in order to keep the application bug free and to maintain our Automation scripts up-to-date, you have to constantly make changes or keep on adding new features and libraries in your code.

For this task, it is necessary that your code is scalable and your framework allows the same which reduces the execution time.


As we now know, that using Selenium Webdriver has both its advantages and disadvantages.

Selenium can also cause problems with respect to pop-up windows, dynamically changing web elements, sync and timeout issues, limited testing, and scalability and framework enhancement.

But also, there are solutions available to limit these problems.

About Techcanvass

Techcanvass offers IT certification courses for professionals. We are an IIBA endorsed education provider (EEP), iSQI ATP (for Certified Agile Business Analyst Training) as well as Agile Testing alliance partner for CP-SAT certification training in Selenium.

We have a Business analyst training course with domain training in-built into it. This training program offers you the opportunity to get certified with ECBA certification as well as have banking domain understanding.

Selenium Certification Training