Selenium Automation Challenges
1) Cross Browser Testing
Sometimes our web application may not response the same in different browsers, and there might be a possibility that our website works fine on Chrome but not on Firefox. Since there are plenty of browsers in the market nowadays, performing test automation on every browser might not be possible. However, we still need to check if the application under test is fully compatible with most used browsers such as Chrome, Firefox, Safari, Edge, and IE. Testing on widely used browsers is still not enough, and we may need to test on widely used versions of these browsers along with different operating systems and resolutions. This strategy sums up to Cross Browser Testing and makes test automation challenging for testers.
The major challenge faced in automation is test scalability. As discussed in the previous point, running tests on different browsers, OS and resolutions is something significant to perform. Selenium WebDriver provides us a way for running tests sequentially and doesn’t offer an effective way to perform Cross Browser Testing. An application under test may grow concerning multiple features with time, which would lead to more test cases, and running multiple test cases sequentially might become a hassle.
To overcome this, Selenium has overcome with Selenium Grid, where we can test our web application on multiple combinations of browsers and OS. However, Selenium Grid would only help perform Cross Browser Testing on the physical machines or browsers that we have, hence running automation tests on the scale becomes challenging for testers.
3) Synchronizing Events
Sync issues are one of the primary reasons for our automation script failure. The sync issues may arise when we expect some event to occur. However, it might get delayed or might not happen due to some unknown reason, which further causes our test case to fail. For example, when we are running an automation script, just after launching the website, we expect a “accept/decline cookies” prompt to come up, but due to some reason, it got delayed, or it didn’t even occur. This type of synchronization becomes the reason for our test script failure.
To handle this, we generally use waits defined in Selenium like Implicit wait and Explicit wait.
4) Handling Dynamic Elements
New websites developed using high technologies might have dynamic content that changes over time. Even the sites that are accessible globally might contain content based on geo-locations.
For example, Amazon is an e-commerce application whose catalog changes overtime and reacts differently with different content in different regions. Automating such web applications becomes challenging with Selenium since the locators that we have used might fail to interact with the web elements. Web content based on AJAX sometimes takes time to load, which also becomes a possible reason for test script failure. As mentioned previously, we have waits integrated with Selenium like Implicit wait and Explicit wait, which can be helpful in such cases. We can even create dynamic or custom XPath for handling dynamic web content.
5) False Positive and False Negative Results
False Positive and False Negative results have always been a nightmare for automation testers. False Positive refers to the scenario where we get errors in our test cases even though the application under test works fine. Vice Versa, false-negative results refer to the situation where we get passing results for our test cases; yet the application under test has bugs. Such flakiness misleads the testing team and increases the communication gap between the QA team and the development team. Handling flaky tests is itself a challenging task for automation testers.
To overcome this flakiness, we need to make sure that the test plans, test cases, and the testing environment are managed in an appropriate and organized manner.
6) Pop up and Alert Handling
Different types of popup and alerts occur while interacting with a web application, below are few listed:
Browser level notification: Examples of such notifications can be; “Allow/Decline camera access,” “Allow/Decline microphone access,” etc. These are browser level notifications that are handled in different ways depending upon the browsers. For the Chrome browser, ChromeOptions can be used. Similarly, for the Firefox browser, FirefoxOptions/FirefoxProfile can be used.
Web-based alerts: Examples of such notifications can be; “This site says….”, “Do you want to leave this site” etc. These are the alerts that can be handled using Selenium predefined class “Alerts,” which provide various methods like accept(), dismiss(), etc.
OS level pop-ups: Selenium capabilities are only bounded with web interaction; hence, handling OS level interactions is something that can’t be performed using Selenium. These types of pop-ups can be categorized as flash objects which can’t be accessed using Selenium Locators. “Robot” class is commonly used for interaction with such pop-ups.
7) Captcha or OTP Handling
As we know, Captcha and OTP cannot be assumed or predicted as its values are different every time it is generated. Automating features like payment gateway, new account registration, etc. where Captcha and OTP is required, becomes challenging for automation testers. This can also be considered as a proof that an application cannot be 100% automated and manual testing cannot be avoided.
8) Limited Reporting
Reporting plays a vital role in the testing phase. Tests reports act as a bridge between developers and testers. As of now, Selenium doesn’t provide much reporting capabilities.
Generating and maintaining reports is the critical challenge faced by automation testers.
We generally use programming language based frameworks for our better code designs and reporting. Examples of Java frameworks that provide useful reports are TestNG, Gauge. Similarly, the Pytest framework can be considered for Python.
9) Restricted to only Desktop Browsers Testing
Nobody can deny the fact that Selenium is a widely used portable framework for testing web applications. However, it doesn't provide support for testing native mobile applications or mobile web applications. For this, we have another open-source framework, "Appium," a.k.a cousin of Selenium. Appium is itself a widely used framework for testing of iOS and Android mobile apps and web apps. Here the challenging part for automation testers is that they have to create different drivers and scripts for testing a single web application in the same browser of desktop and mobile while working in a software testing company.
Wrapping it up
IT field is something where you would face my challenges since the technology is growing up with high speed. Not only the Selenium-based testers are facing challenges but also the testers who are using other testing tools like QTP, Katalon, Ranorex, etc. are also facing challenges in respective projects. But we have to accept the fact that every good thing comes up with some limitations as well, nothing is perfect in this world. To overcome the above-mentioned challenges, I have also given the workaround that might help in your on-going projects. Apart from this, there are various testing communities where you can interact with people to know how they have overcome such challenges.