In the tech world, tools and technologies evolve at a rapid pace, and, Software Testing does not make an exception. In the last years, a LOT of tools have been born (such as Cypress, Playwright, Robot Framework, etc.), each one having its unique traits and approach for resolving the same problem: Test Automation.
However, only one framework has been a cornerstone in the field of test automation for years: Selenium. It has been around and open-source for over 15 years, until recent times when a growing debate emerged: Is Selenium dead? Is there a better alternative? Has it lost its relevance in the face of new testing tools and approaches?
In this article, we will take a deep look into the current state of Selenium in 2023, exploring its strengths and weaknesses compared to its competitors, and the challenges it faces in a rapidly changing landscape from my own point of view.
Pre-requisites:
- Being a QA enthusiast 😉
The Rise and Dominance of Selenium
Selenium was initially developed by Jason Huggins in 2004 as a JavaScript-based automation tool (named JavaScriptTestRunner) to automate the testing of an internal application that was taking a hard manual effort. Over the years, and as he realized the potential of the program, it evolved into Selenium-core and was open-sourced. Then, through multiple contributors that implemented a lot of features such as
Selenium IDE: which enabled to running of automated tests through the record and playback feature
Selenium Grid: a powerful functionality that enables performing parallel testing which addresses the need to reduce time spent on test execution to a minimal
Selenium 2: This is a merge between Selenium 1 and Webdriver to form the tool that we know today.
Since Selenium 2, it gained a lot of traction and its popularity has risen rapidly, which can be attributed to several key factors that were game changers:
- Open Source: Selenium is open-source, which means it’s free to use and has a large community that will get you out of any problem you face, and a lot of contributors and users. This has led to continuous improvements and updates.
- Cross-Browser Compatibility: Selenium supports various web browsers like Chrome, Firefox, Safari, Edge, and Internet Explorer, making it a versatile choice for web application testing.
- Multiple Programming Languages: Selenium is compatible with A LOT of programming languages, including Java, Python, C#, Ruby, JavaScript, and lately Kotlin. Test automation engineers can choose their preferred language for test automation.
- Wide Adoption: Many organizations and companies have incorporated Selenium into their test automation suites, leading to a vast amount of resources, tutorials, and support available online. (As of now, I am managing a Selenium suite myself for my employer’s company 😉 )
- Integration with Test Frameworks: Selenium can be integrated with popular test frameworks like TestNG and Cucumber, allowing for structured test case management and reporting.
- Parallelism: Selenium supports a powerful parallelism of test cases using Selenium Grid which reduces greatly the time of execution.
Is Selenium Dead? The Current State of Selenium
As of 2023, Selenium is far from dead. It remains a vital tool in the arsenal of many software testing teams worldwide, mainly due to the same factors that made it popular from its debut.
Let’s examine some key aspects of its current state:
- Continued Development: The Selenium project continues to release updates and improvements. The community is active, addressing issues, adding new features, and ensuring Selenium remains compatible with the latest browser versions.
- Large Community: Selenium’s user community is substantial, providing a wealth of resources, forums, and discussion groups where testers can seek help and share knowledge.
- Compatibility: Selenium WebDriver is still compatible with all major browsers, ensuring that testers can perform cross-browser testing effectively.
- Programming Language Support: Selenium offers support for various programming languages such as Java, JavaScript, Ruby, C#, Kotlin, etc. making it adaptable to your team’s preferences and tech stack.
- Integration and Ecosystem: Selenium can be integrated with various tools and frameworks, such as TestNG, Cucumber, and Jenkins for CI/CD, enhancing its capabilities and facilitating seamless automation workflows.
- Cloud-Based Testing: The integration of Selenium with cloud-based testing platforms has made it easier to execute tests on various browser versions and devices, enabling broader test coverage.
Selenium Last Version: 4.0 features
- Improved Selenium Grid: Anyone who worked with Selenium Grid before knows it is a headache to set up. New Selenium Grid comes with docker support, enabling us to spin up containers smoothly and in 3 modes : Standalone mode, Hub and Node, or fully distributed.
- Upgraded Selenium IDE: The old IDE was deprecated due to new browser’s version. It is new revived and provides rich features like: Intuitive GUI, Improved control flow mechanism, enhanced element locator strategy and now, tests can be exported in any language supported by Selenium.
- Improved Documentation: The documentation has been re-written in an awesome way so that it has a neat UI, and it covers everything you need to know about Selenium, I strongly encourage you to take a look at it if you’re starting with Selenium.
- Relative Locators: Selenium 4 introduced a new way of locating elements using relative intuitive terms such as: To left of, To right of, Above, Below.
- Better Window and Tabs Management: In Selenium 3, opening a new window needed much “hacking”. So, the Selenium community offers now a new API: “newWindow” that allows users to create and switch to a new window/tab.
driver.get("https://www.google.com/");
// Opens a new window and switches to it
driver.switchTo().newWindow(WindowType.WINDOW);
// Opens SDETUNICORNS homepage in the new window
driver.navigate().to("https://sdetunicorns.com/");
Frameworks based on Selenium
What makes Selenium widely used is also the enormous ecosystem built on top of it. Here are some frameworks that are built on top of Selenium and that are really interesting and widely used:
Java: FluentLenium, Selenide
Python: Robot Framework, SeleniumBase
JavaScript: CodeceptJS, Nightwatch.js, Boyka Framework
C#: Atata, Boa Constrictor
I strongly recommend that you take a look at these frameworks as they constitute a wrapper that addresses a lot of pure Selenium pain- points.
While Selenium remains highly used, you will encounter some challenges that may or may not cripple you in your test automation journey.
Here are some limitations that I face using Selenium :
- Complexity: Selenium automation can be complex, especially for beginners. Setting up and configuring the environment, writing stable and maintainable test scripts, and dealing with dynamic web elements can be daunting when starting, which results in a bigger learning curve.
- Flakiness: Selenium tests can be prone to flakiness, meaning they may produce inconsistent results due to factors like network latency, browser behavior, or element visibility (because Selenium was not designed for recent front-end frameworks). Test flakiness can be frustrating and time-consuming to address.
- Debugging: Selenium lacks a useful functionality compared to its competitor: Snapshots. They enable you to track your code and its results in the browsers and greatly facilitate debugging by enabling you to go back in time to a precise line of code and see its results in the browser.
Quick anecdote: I was working on a Cypress test suite, I changed jobs and found myself with a whole Selenium test suite between my hands. I had a HARD time debugging failing tests and I missed my Snapshot a LOT. But truth is, not having a strong debugging tool made me more aware of my code and I learnt to be more attentive to details.
Alternatives to Selenium
Let’s take a look at the most popular Selenium alternatives and compare them.
- Cypress: Cypress
is a JavaScript-based end-to-end testing framework that emphasizes speed and reliability. It provides real-time reloading and Snapshots whi and excellent support for modern web applications.
Pros:
– Has Snapshots functionality which facilitates greatly debugging
– Better User Interface and developer experience
– Lesser learning curve when starting - Playwright: Developed by Microsoft
, Playwright is a cross-browser and cross-platform automation library for JavaScript and Python. It offers a unified API to automate browsers (Chrome, Firefox, WebKit) and supports multiple languages such as TypeScript, JavaScript, Python, .NET, and Java.
Pros:
– More features built-in
– Better Debugging tooling
– Way easier to get started - WebDriverIO: WebDriverIO
is an automation test framework rooted in NodeJS. The official website defines WebDriverIO as “a progressive automation framework built to automate modern web and mobile applications. It simplifies the interaction with your app and provides a set of plugins that help you create a scalable, robust, and stable test suite.”
For those looking to get started with WebDriverIO, we have a dedicated course to guide you.
Pros:– Support browser, desktop, and Mobile testing.
– Built for testing modern web applications written in React, Vue, Svelte, and other front-end frameworks
Conclusion
To wrap it up, in 2023, Selenium is far from dead.
It still occupies the throne of the most popular tool used in organizations.
We can argue that it is mainly due to most codebases being old, but, it is still relevant. There is huge traction and massive job openings for the Selenium skillset worldwide. Companies have gigantic test suites based on Selenium. And, just like any codebase, they need maintenance, new features, and updates. All of that ensures that the Selenium community will only get larger and its contributors will multiply.
Even in the startup world, I see demand for Selenium automation and that’s mostly because there is no doubt about its efficiency and resilience.
However, I can not deny that it does face some challenges: From test script complexity to debugging combined with the emergence of alternative more feature-rich testing tools.
The future of Selenium will depend on its ability to adapt to changing testing trends and technologies as it did before. With ongoing development efforts, integration with cloud-based services, and improvements in debugging tools and reporting, Selenium can keep its throne of software automation king.
Ultimately, if you need to choose between Selenium and other alternatives, your choice should be driven by the specific requirements of your testing project, the skills of your team, and the evolving needs of your organization. Selenium might be the most popular, but that does not make it the best tool for all use cases.
References