In the mid-2000s, Selenium was first introduced as a Web browser extension to record and playback interactions with Web browsers. Over a decade, it has become the most recognized tool for test automation. 80% of people who were asked in a survey conducted in 2018, said that they use Selenium for their software testing activities.
Selenium is an open-source framework used to automate web applications. It includes Selenium WebDriver, Selenium IDE, and Selenium Grid.
- Selenium WebDriver: a core automation component that drives user interactions in browsers, serving as the foundation for the other components. It is designed as a concise and compact programming interface.
- Selenium IDE: a browser extension (Chrome and Firefox) that records and plays back user interactions in the browser.
- Selenium Grid: enables WebDriver to run automation tests on many machines, browsers, and operating systems simultaneously.
People can quickly point out this framework’s critical advantages as the main reasons why it is widely adopted in the software automation community. The first advantage is that it’s developer-friendly: allows developers to write and test in any programming language. Second, it is cross-browsers and cross-operating systems. Teams can perform test automation on many browsers and operating systems, which is an ultimate requirement for the automation testing success.
From the architectural perspective, we will discuss the main reasons for Selenium’s popularity and how it could remain the dominant position for Web-based automation in 2020 and even further.
Selenium WebDriver Architecture
First, let’s take a look at the diagram below. It simply presents Selenium WebDriver architecture, which includes three components: WebDriver, Browser Specific Drivers or Drivers, and Browser. The interaction between these components is bidirectional, sending HTTP requests, and receiving HTTP responses in forms of RESTful services.
- Browser Specific Drivers or Drivers are responsible for controlling the actual browser by relaying requests from WebDriver. Drivers are provided specific to each browser and they usually run on the same system as the browsers. Drivers are also particular to the language which is used for test case automation like Java, Python, C#, etc. Plus, third parties can implement and extend drivers. GeckoDriver for Firefox and ChromeDriver for Chrome are two driver implementations for these browsers.
- Browser is the actual browser that receives the requests from the Drivers component and drives interactions on the Application Under Test (AUT). Selenium provides support for multiple browsers such as Chrome, Firefox, Internet Explorer, Safari, and Opera.
WebDriver can run on another system from the Drivers and Browser components. In this setting, WebDriver communicates remotely with these components via Selenium Server or Remote WebDriver. Thus, Selenium can run automation tests on different browsers and machines at the same time.
Selenium Architecture’s Advantages
Selenium architecture constrains some key characteristics. It is robust and straightforward, with just a few components, each having specific responsibilities performing the automation tests writing and execution on the AUT.
Loosely coupled architectures (aka Microservices) is what we can say about Selenium. Three components communicate via the HTTP protocol with RESTful Web services, which allows a component to be separated from one another. Enhancements and changes to one can be made easily and without affecting the others. This kind of architecture allows Selenium to be platform-independent and language-neutral.
Additionally, Selenium WebDriver is a W3C Recommendation. This open architecture enables the unlimited contributions provided by the software community.
These architecture’s characteristics bring out many critical features of Selenium:
- Developer-friendly. As mentioned, Selenium supports the most commonly used programming languages. The language limitation does not prevent developers, they can create test scripts using their most comfortable language(s). In many cases, they can build and integrate a binding library in the WebDriver component to support their new scripting language.
- Open to extensions. By supporting new test scripting languages or Drivers for new browsers, Selenium enables possible extensions of language bindings.
- Open to the integration with test automation solutions. Test automation solutions can be built on top of Selenium via using it as a core engine for script execution, serving Web test automation. Since Selenium is not an all-inclusive web automation testing solution, it needs to be integrated with third-party tools and add-ons to broaden the test scope. For example, to manage test cases and generate reports, there must be an integration between Selenium and tools such as TestNG or JUnit.
- Cross-platform and cross-language. Users can execute automation scripts on multiple operating systems and browsers due to the availability of many implementations of the Drivers component. Also, Selenium automation scripts can be written by multiple languages as long as language bindings in the WebDriver are available. Just as importantly, automation tests can be run on different machines and browsers simultaneously by adding a Selenium Server or Remote WebDriver.
Other advantages that Selenium’s lovers can easily list down:
Open-source and free for all
- A huge and supportive community is always available to help of case of need
- Constant and sustainable growth is a thing that Selenium’s fans can lean on. With such an enormous and worldwide community, Selenium can be well maintained and upgraded for the sake of the community
- Bunch of Selenium training resources/tutorials are available out there
The Rising Demand of Selenium-based Test Solutions
Besides the advantages of Selenium in supporting programming, it has disadvantages, especially for those who do not have advanced programming skills. Programming knowledge and experience is quite a necessary condition for users to build and write Selenium tests effectively. For instance, many Testers and Business Analysts consider Selenium as an encumbrance because of its steep learning curve to start their test automation journey.
Selenium also has limited mechanisms to separate automated scripts from test data, which causes high maintenance cost of test scripts as well as difficulty in the test script and test data reusability. Besides, there is also a lack of capability to manage and organize test assets such as test scripts, data, and test objects.
Due to the shortage of many components for a comprehensive automation project, such as reporting and logging, teams have to possess expertise and experience to build, customize, and maintain a Selenium-based tool for their projects. It will be time-consuming and can not apply to projects that need to be completed within a short period of time. This can also affect the time to market a product. Also, to effectively use Selenium, the whole team needs to attain an equal level of knowledge and experience. Last, without thorough planning and architecting, such frameworks are not reusable across projects. These requirements are not easy to achieve for every team. And, that’s the time for the rising demand on Selenium-based test frameworks which eliminate the disadvantages of Selenium and accelerate the advancement of the core engine.
The Architecture of Selenium-based Test Solutions
It’s not difficult to name test automation frameworks out there built on top of Selenium. These frameworks help address the limitations of Selenium, from fulfilling the shortage of modules for reporting, logging, monitoring, and reusing test automation assets to erasing the steep learning curve. Importantly, these tools lay down the burden of building and starting the automation effort using Selenium. All drivers, dependencies, and libraries needed to automate your test activities are included in the framework. With those that are not covered within a framework, integrations and plugins can help.
This diagram shows various components of a typical test framework that uses Selenium as its test execution engine. Core components of this sample framework consist of Common Libraries, Report and Logging, Data Management and Connectivity, Test Organization and Management, Monitoring, Test Execution, and Scheduler. Data is stored in databases, files, or internal data structures separately from test scripts. An open test framework also allows Application Lifecycle Management (ALM) extensions integrating test activities and assets into the whole ALM process.
Many existing automation solutions implement this Selenium-based framework. Katalon Studio, Lambda Test, Sauce Labs are a few examples of such solutions. Some of these even go further with the integration of Appium as an engine for mobile apps testing. This helps extend the test capabilities of a solution and makes it a step closer to become an all-in-one solution.
This kind of framework does not come with only advantages. An obvious limitation is that users cannot use the programming languages of their choice but choose among the list of languages offered by the solutions.
Another disadvantage is the cost of migrating test scripts, data, and other test assets from one tool to another. The mismatch in organizing test assets between tools makes it challenging for migration. For example, scripts in a language may not be compatible when migrating to a tool that does not support that language. Recently, codeless test automation tools, some can be named as Katalon or TestComplete offer the migration feature, which helps users effortlessly migrate their current Selenium tests (and tests from other frameworks) into the tools. This allows users to reuse, maintain, and develop the tests in a much easier way without starting from scratch.
We’ve been through the introduction of Selenium WebDriver architecture, which explains its continuous dominance in the Web test automation landscape. Simple, robust, loosely coupled, and open are critical characteristics of the architecture. These characteristics make it cross-platform, cross-language, and open for extension. On the other hand, the framework’s limitations come from its design.
With the inherent advantages of Selenium architecture and the availability of Selenium-based tools, Selenium will continue to dominate as the framework for Web test automation. However, since there is no one-size-fits-all solution, along with Selenium, comprehensive but codeless test automation tools will continue to show the important role in the test automation landscape.