Introduction To Selenium Test Automation Tool
Selenium automates browsers; that’s it! What you do with that power is up to you. You can use this tool to do administrative tasks like filling timesheets, web scraping, or the Selenium automation tool to test web applications. (Source — Selenium official website)
Selenium test automation tool is a library in various language bindings like Java, PHP, Javascript, C#, and Python. It can automate the user actions like clicking, entering text in the fields, etc.
To use Selenium, as a test automation tool, is integrated with testing frameworks like TestNG or JUnit (for Java), NUnit (for C#), Pytest(for Python), and Mocha framework (for javascript).
All these testing frameworks provide a way to create, maintain and execute test cases; assertions mark test cases as pass or fail based on the testing criteria.
Components of Selenium
Selenium is not just a single tool but a suite of tools. It can majorly be classified into three components —
- Selenium IDE
- Selenium WebDriver (version 4)
- Selenium Grid
PS: previously, there were four, and Selenium RC is wholly deprecated now.
Selenium IDE
Selenium IDE comes as a plugin (or extension) and is available for both “Chrome” and “Firefox” browsers. This tool provides mechanisms to record your test cases and replay them. It also provides the capability to extract the code in Selenium Webdriver format in different language bindings (Java, C#, PHP, Python, Ruby, etc.). Even though it’s an excellent tool, it has many limitations in automating and testing complex scenarios.
Selenium WebDriver (version 4)
Selenium WebDriver (version 4) is the most critical component of Selenium and can automate all complex UI scenarios in the language of your choice.
The architecture of Selenium 4.
Selenium 4 communicates with the browser via the browser driver using the w3c protocol. The browser driver comes as an executable file and differs for different browsers.
What is W3C (World Wide Web Consortium)?
The W3C (World Wide Web Consortium) is an international organization that creates standards for the world wide web. The WC3 is committed to improving the web by setting and promoting web-based standards.
The W3C’s goal is to create technical standards and guidelines for web technologies worldwide. These standards are intended to keep a consistent level of technical quality and compatibility concerning the World Wide Web. Developers who create web applications can have confidence in the tools they’re using, as experts have vetted web applications using these standards.
An example of a W3C standard is web browsers. Most use W3C standards, which enables them to interpret code such as Hypertext Markup Language (HTML) and Cascading Style Sheets (CSS).
Now coming back to the architecture of Selenium 4.
The browser driver communicates with the respective browser via HTTP protocol.
All three components, browsers (chrome, firefox, edge, etc.), browser driver (comes as executables), and Selenium client libraries, are w3c complaints. Until Selenium 3, all the communication happened over the JSON wire protocol.
W3C stands for World wide web consortium. W3C standards define an Open Web Platform for application development with the unprecedented potential to enable developers to build rich interactive experiences powered by vast data stores available on any device.
Selenium being a W3C complaint, improves stability and provides better and fast communications since they all speak the same language.
Selenium 4 architecture design
Selenium Grid
Selenium Grid is another component from selenium suites of the library that is used to execute tests in parallel on the same machine or different machines. This reduces the time of execution and reduces the feedback loop.
It can also be integrated with containerization tools like docker to make the execution of tests faster.
Selenium Grid
Features of Selenium test automation tool
Some of the features that made Selenium famous are —
- Open source, it’s completely free to use, no cost involved.
- Multiple language support, choose your language to work with Selenium. Selenium library comes in different languages (Java, Python, Perl, Ruby, PHP, C#, Javascript)
- Selenium can work on almost all operating systems with multiple platform support, be it Windows, Mac, or Linux.
- With multiple browser support, Selenium works with all the major browser vendors like Chrome, Edge, Firefox, Safari, and all other modern-day browsers. Many cloud solutions, like Labda test, browser stacks, etc., can be used for responsive testing or browser compatibility testing.
- Easy integrations, Selenium integrates well with other libraries (reporting libraries like ExtentReport, Allure reporting, etc.) and frameworks like testing frameworks (TestNG, JUnit, PyTest, NUnit, etc.)
- Community support, Selenium has been in the market for more than a decade now, and so is its community. There are 100s of people out there to help you with your queries. You can find these people on Stackoverflow, Github, etc.
- Learning support, Many good courses (free or paid), and other resources are available all over the internet to help you learn Selenium.
Limitations of the Selenium automation tool
Selenium is a great tool, but it has a lot of limitations —
- It can only automate web applications, not desktop applications.
- No API testing support; it can only automate the user actions on web applications but the APIs. There are modern test application tools like Cypress that can help automate not only UI but also API.
- No performance testing support, Selenium is not a tool for performance testing and should not be used for it.
- No image testing support; Selenium does not have the capabilities to test images.
Thanks for reading this article where we discussed what Selenium is. Features of Selenium, different components of Selenium, and limitations of Selenium.
If you have any questions, reach out to saurabh@qatechhub.com