We all know that Software Testing is an integral part of SDLC, and sometimes it involves a lot of repetitive tasks, combing over scenarios over and again. Now to reduce these repetitive efforts, software testers need the help of some tools that can enable them to automate these repetitive tasks. One of the great suites of automation tools is Selenium, which provides the capabilities to automate user actions on a web application. It is an open-source umbrella project for a range of tools and libraries that enable and support the automation of web browsers. Let's understand in this article all the intricacies of Selenium Testing by covering the details across the following topics:
- What is Selenium?
- How Selenium originated?
- What are the various components of Selenium?
- Selenium IDE
- Selenium RC
- Selenium WebDriver (Selenium 4)
- Selenium Grid
- Why is Selenium popular and What is selenium testing used for?
- What Selenium testing can do?
- What Selenium cannot do?
- What are the prerequisites for learning Selenium?
- Which Selenium Testing tool fits your need?
What is Selenium Testing?
As we discussed, Selenium is a set of open-source web automation tools that leverages the power of web browsers and helps automate workflows of how users interact with the web application within the browser. The primary purpose of Selenium, as highlighted by the Selenium Website, is - "Selenium Automates Browsers, What you do with this power is entirely up to you". Even with the emerging tools and technologies, Selenium is still leading the board in the list of Web Automation tools and Automation Testing. The below survey conducted by Katalon depicts the popularity of Selenium in testing:
Such a popular tool with such a broad audience, it is important that before understanding the further details of the Selenium testing, let's brief ourselves how Selenium came into existence and what was its initiating point:
How Selenium originated?
The history of Selenium dates back to the early 2000s. Jason Huggins, an engineer in ThoughtWorks, created a JavaScript module. Its name was JavaScriptTestRunner, for the automation of an internal website. The name Selenium comes from a joke made by Huggins, saying that "you can cure mercury poisoning by taking selenium supplements". Even though this was just a joke while mocking a competitor named Mercury, others who received the email with the joke, took the name and ran with it. The following figure shows the evolution of Selenium throughout the years:
What are the various components of Selenium?
As we discussed above, Selenium is not just an automation tool. It is a suite of tools, and each tool in the suite has specific unique capabilities that help in the design and development of an automation framework. All these components can be either used individually or can be paired with one another to achieve a level of test automation and hence, contribute to Selenium testing.
The below figure shows various components of the Selenium Suite:
Let's understand all these components in more detail:
What is Selenium IDE?
Selenium IDE is an extension available for both Firefox and Chrome, which has the record and replay functionality available. Selenium IDE also now has the capability of exporting the code in various predefined languages. It also gives the ability to use one test case inside another.
What is Selenium RC?
Selenium RC is a server that acts as a middleman between the user and the browser that needs to interact. RC uses Javascript to work with browsers while allowing the users to write code in the language of their choice. It was the main version of Selenium testing for some time. Selenium RC had issues with the One Origin Policy and was deprecated in favor of WebDriver.
What is Selenium WebDriver?
Selenium WebDriver is the most commonly used component of Selenium testing. WebDriver allows users to write custom code in their language of choice and interact with the browser of their choice, through browser-specific drivers. WebDriver works on the OS level and uses a Protocol called JSONWireProtocol to communicate with browsers.
As shown above, Selenium 2 was the actual implementation of the merger of the WebDriver and RC project. The features of WebDriver and RC were imbibed in version 2 of WebDriver and called Selenium 2.
Selenium 3 was an upgrade over Selenium 2 in many terms. Selenium 3 became a World Wide Web Consortium (W3C) standard. Selenium RC moved to a legacy package, and many improvements and new features were added to cater to the changing web landscape.
Moreover, Selenium 4 is the new member of the family (selenium latest version) about which we have written a complete post that can be found in the index.
What is Selenium Grid?
Selenium GRID allows users to run tests on different machines, with different browsers and OS simultaneously, which gives the ability to run tests in parallel, as such saving a lot of time and resources testing on several machines.
Why is Selenium popular and What is selenium testing used for?
Selenium has become one of the most popular tools for automating web applications with a big community behind it. Big multinational giants like Google, Apple, Amazon, and many other Fortune 500 companies use Selenium daily and have even provided support to the tool. The original Selenium contributors are still actively contributing continuously, which has enabled Selenium to be up to date with the challenges of modern web application testing.
Also, as we discussed, the Selenium suite of tools, which comprises different components like Selenium IDE, WebDriver, Grid,, etc. are available for automation across different browsers, platforms, and programming languages. Selenium testing also supports all major operating systems like macOS, Windows, and Linux, and has support for mobile operating systems like iOS, and Android as well. The below figure shows a few of the standard features that contribute to the popularity of Selenium:
Apart from this horizon, let's understand what Selenium testing is capable of doing.
What Selenium testing can do?
There are a lot of capabilities that Selenium testing provides which contribute to its being one of the most liked automation tools in the market. Let's take a quick sneak on those capabilities:
- Open Source – Unlike tools like QTP, Selenium is open source, which means that no cost is required to set up and use Selenium. Selenium is free to download and use.
- Mimic User Actions – Almost all real-world user actions like button click, drag, and drop selection, checkboxes, keypresses, taps, and scrolling can be automated using Selenium testing.
- Easy Implementation – Selenium is famous for being user-friendly. Users can develop custom extensions for their use since the code is open source.
- Language Support – The most significant benefit of Selenium is the extensive support for various languages. Selenium supports maximum programming languages like Java, Python, JavaScript, C#, Ruby, Perl, Haskell, and Go, among others.
- Browser Support – Selenium can work on all the browser vendors that are out there. Selenium has support for Chrome, Firefox, Edge, Internet Explorer, Safari.
- OS Support – Selenium bindings are available for all the primary OS like Linux, macOS, and Windows.
- Framework Support – Selenium testing supports multiple frameworks like Maven, TestNG, PYTest, NUnit, Mocha, Jasmine, etc. Selenium integrates well with CI tools like Jenkins, Circle CI, GOCD, Travis CI, Gitlab, etc.
- Code Reusability – Scripts written for Selenium are cross-browser compatible. The same code can be run for multiple browsers using respective browser binaries and on separate machines in a Grid configuration,
- Community Support – Since there are a lot of QA's working on this tool, it is effortless to find resources, tutorials as well as support on communities like GitHub, StackOverflow, etc.
Apart from the capabilities, mentioned above, as we discussed, Selenium testing supports a wide range of web browsers, programming languages, and operating systems. The following figure shows a few of them:
It is not an exhaustive list but certainly gives a basic idea about the broad support that Selenium provides across the platform. Now, apart from these capabilities, there are certain limitations also which Selenium is not capable. Let's understand them:
What Selenium can't do?
Although Selenium testing can help in the automation of a lot of user actions, there are certain limitations to it also. A few of them are:
- No support to automate native desktop-based applications- Selenium can be used to automate web-based applications that run on web browsers. However, it cannot automate desktop-based applications.
- No support for assertions and validity - Selenium provides control to the browser; however, providing assertions and checking mechanisms is not provided by Selenium. Selenium needs to pair with a testing framework like JUnit, TestNG, PyTest, etc. for assertions.
- No support for image and code scanning - Automation of code scanning scenarios such as Bar code reading, and CAPTCHA is not possible using Selenium testing.
- No support for API Testing - Selenium mimics the user actions on the browser. So as such, Selenium doesn't give the capability of testing API.
- No support for Performance Testing - Selenium cannot perform performance checks or performance testing of the web applications.
- No inbuilt Reporting - Reporting capability is also not provided by Selenium. That is to say; reporting can be done only by pairing it with a framework like JUnit, TestNG.
What are the prerequisites for learning Selenium testing?
Even though it's straightforward to learn and kickoff automation of web applications using Selenium, it is always useful to ensure that the user knows the following concepts, before starting to learn about Selenium:
- The user knows the basics of manual testing
- Basic knowledge of coding in a programming language that Selenium supports.
- The user has basic knowledge of HTML, CSS.
- Additionally, they possess the basic knowledge of XML and JSON.
- Moreover, they know DOM and identify a web element using a locator in DOM.
However, it is not necessary to know of all these. ToolsQA has specially designed their Selenium testing tutorial so that a novice can pick up and learn automation quickly. With these Selenium WebDriver tutorials, you should be able to start your journey of Selenium testing. In fact, if you like to be called Selenium Professional we recommend you take the Selenium Certification as well.
Now before jumping to the usage of the Selenium suite, the first confusion that comes is which Selenium tool needs to use for which type of scenarios. Let's understand a few of the situations where a particular Selenium tool will fit the needs:
Which Selenium Testing tool fits your need?
Since there are multiple components of Selenium, it may be not very clear for people who are new to Selenium to decide which part to use for their automation needs. You can use the below guide to select which Selenium component will fit your needs the best:
- Selenium IDE
- If you want to learn about automation testing and Selenium.
- If you have little or no prior experience in test automation.
- In case you want to write simple test cases and export them later for RC or WebDriver.
- If you want to execute customized JavaScript code using runScript
- If you want to export the script in various languages.
- In case you want to target Chrome and Firefox for testing.
- Selenium RC
- If you want to write test cases in more expressive language than IDE.
- If you want to test the application against a new browser that supports JavaScript.
- Or, if you want to test an application, that is AJAX heavy.
- Selenium WebDriver
- If you want to use a specific programming language for your automation test cases.
- If you want to test applications in different platforms using Selenium Grid
- Or, if you want to test applications in CI/CD.
- If you want to test applications and generate customized HTML formatted reports.
- If you want to test modern dynamic data-heavy websites.
- Selenium GRID
- If you want to run your automation test cases in different browsers and operating systems simultaneously.
- If you want to run a vast test suite and want to minimize the execution time.
Key Takeaways
- Selenium is an all-purpose web automation tool that caters to the significant needs of web application automation.
- Moreover, Selenium is a suite of tools that consists of various components - IDE, RC, WebDriver, GRID.
- Selenium WebDriver is the most popular tool of the Selenium suite.
- In addition to the above, the primary reason for the popularity of Selenium testing is due to its wide coverage and support for different OS, Programming languages, and Web Browsers.
By now, we all should be clear about the basics of Selenium testing. Let's move to the next article, where we will learn about the details of "Selenium WebDriver".