Components of the Selenium Automation Tool
Learn the basics and different parts of Selenium for test automation and its pros and cons.
Join the DZone community and get the full member experience.Join For Free
Selenium is one of the most popular tools used for automating web applications. It is an open source tool used for the execution of test scripts or test cases on web applications.
Selenium is also platform independent. The code or framework, developed using C#/Java, can be executed on different platforms/operating systems like Windows OS, Mac OS, and Linux.
Selenium is a library which consists of classes, methods, interfaces, etc., which can be used and integrated with the various programming languages mentioned above.
For the above reasons, most top companies prefer Selenium rather than using Quick Test Professional (QTP) or CodedUI, which are both licensed versions.
Selenium supports various browsers such as Google Chrome, Edge Browser (Windows 10), Firefox Browser, Internet Explorer, Safari, etc. Each browser has its own driver for executing test scripts on their browsers; for example, to execute Selenium scripts on Chrome, we have Chromedrivers. Internet Explorer (IE) driver and GoogleChrome driver support both 32-bit and 64-bit versions, which we can download and use based on our system requirements.
In earlier versions like Selenium 1.0 and Selenium 2.0, we weren't required to set up Firefox drivers to execute scripts on the Firefox Browser. By default, Selenium has support for Firefox. In Selenium 3.0, all the vendors like Google, Apple, Microsoft, and Firefox have their own drivers to work with Selenium.
Selenium Webdriver and Selenium Grid
Later, Paul Hammant joined his team and developed the other version of Selenium, Selenium RC. This tool became open-source to work with the different browsers and platforms. Simon Stewart at ThoughtWorks developed an automation tool for the browser known as Webdriver, and later, they merged Selenium RC with Webdriver to create Selenium Webdriver (Selenium 2.0).
Philippe Hanrigou at ThoughtWorks developed Selenium Grid in 2008. Selenium Grid is used for configuring single hub and multiple nodes. The current hub is capable of running multiple test cases on client machines as well as remote machines, which reduces the time as well as resources.
Finally, Selenium 3.0 was developed this year, with new features. It is a combination of Selenium 2.0 and Selenium 1.0, which means it supports Selenium 2.0 features but it doesn’t have support for Selenium 1.0, i.e. Selenium Core. Please refer to my article to learn more about Selenium 3.0.
When Selenium was in development, one of the most popular testing tools was called QTP (Quick Test Professional), was developed by Mercury Interactive before it was acquired by HP. QTP was Selenium's competitor they have named their product based on the element selenium. As we know the chemical element term Selenium (Se) is capable of poisioning/detoxifying Mercury. so the term or the product was named Selenium.
This was a brief introduction about Selenium, let us look into various components of Selenium.
Components of Selenium
Selenium IDE is also known as an Integrated Development Environment, which is a GUI based application. It supports Edit, Record, and debugging features, also called Record/Replay or Record/Playback. It is a Firefox Add-on/Extension which works only in the older version of the Firefox browser. We can navigate to Firefox Add-on/Firefox Extensions in the Firefox browser and search for "Selenium IDE" and install it.
In Selenium IDE, the execution of test cases is very slow, and the report generation step for the test cases is not good as compared with other components. It doesn't support execution of test cases in parallel or remote execution. The Selenium IDE has Command and target textboxes, and commands are used for actions like clicking; type on a particular control and target to specify the control properties.
Export is used to export the Selenese scripting to C#, Java, PHP, etc.
As it doesn't support any programming languages, we can't apply any logic or conditions to the test cases. Refer to these links for the installation process:
The drawbacks of Selenium IDE:
- The test cases can be executed in only in the Firefox browser.
- The execution of test cases is very slow and the report generation step is not good when compared with other components.
- It doesn't support mobile-based testing like iPhone/Android testing.
- It doesn't support parallel/remote execution of test cases.
- It doesn't support logical/conditional statements because it is easy to use without any programming languages.
- It doesn't support any complex scenarios/test scripts/test cases.
- To overcome the above problems, we have another component of Selenium: Selenium RC.
Selenium RC is also known as Selenium Remote Control. As the starting version of Selenium, it doesn't have any GUI interface; rather, it contains libraries or APIs which consist of various classes, methods, and interfaces which are used with various programming languages like C#, Java, PHP, and Perl. It is based on object-oriented programming principles.
As Selenium RC was developed using Java, it is recommended to use with Java, as it supports language independence so we can integrate Selenium RC with other languages like C# as well.
Unlike Selenium IDE, the execution of test cases can be executed only in the Firefox browser. Selenium RC is the advanced version of Selenium IDE, which allows you to execute the test cases or test scripts in various browsers like Chrome, Firefox, IE, Safari, and Opera. Selenium RC supports language independence, which means we can integrate Selenium RC with any of the above languages like C#, Java, and PHP. It also supports platform independence which means the scripts/code written using C#/Java can be executed in various platforms like Windows OS, Mac OS, and Linux.
Some other features of Selenium RC:
- It doesn't support mobile testing like iPhone or Android.
- It is based on a client/server architecture, which means whenever we want to execute the test cases/test scripts, we need to start the server manually.
- It supports parallel execution of test cases as well as remote execution with the help of Selenium Grid.
The drawback of Selenium RC is that whenever we want to execute test cases, we need to start the server or Selenium server manually. The code doesn't interact directly with the browser; the mediator is required. To overcome this problem, we have another version of Selenium: Selenium Webdriver.
To overcome the above problem with Selenium RC, Webdriver was developed. Webdriver is a combination of Selenium RC and Webdriver. Selenium Webdriver doesn't require starting the server/Selenium server to execute test cases.
It supports programming languages like C#, Java, PHP, Perl, and Python and various platforms to execute test cases, like Windows OS, Mac OS, and Linux. It supports parallel as well as remote execution.
Unlike Selenium RC which requires Selenium Server as a mediator to start for the execution of test cases, Selenium Webdriver doesn't need to start the server, which interacts directly with the web browser to execute the test cases.
It's a library/API which consists of various methods/classes/interfaces to use with various programming languages like C#, Java, or Python.
Each browser has its own drivers:
- To execute a test case in Chrome, we have Chromedriver.
- To execute a test case in Firefox, we have Geckodriver.
- To execute a test case in Safari, we have Safaridriver.
- To execute a test case in Internet Explorer, we have IEdriver.
- To execute a test case in Opera, we have Operadriver.
It also supports execution of test cases with the ajax based application. The above drivers can be downloaded from Selenium HQ.
Selenium Webdriver supports execution with mobile-based testing like Selendroid or Appium.
It is a tool which is used for the execution of parallel as well as remote execution by using Selenium RC or Selenium Webdriver.
For the execution of test cases in remote machines connected over LAN networks, we need to configure a hub and node. The hub acts as a mediator or like a server and multiple nodes are configured to a hub.
If we want to execute the test cases, say 6 different test cases with 3 different nodes connected to a hub, then the hub's responsibility is to distribute the six different test cases among 3 different nodes which are connected to a hub.
If Chrome, Firefox, and Opera are connected to a hub then two cases will be executed in Chrome, two in Firefox, and two in Opera. With the help of parallel as well as remote execution, the test cases will be executed in various machines which are connected via LAN network which saves a lot of time and human resources.
Thanks and I hope this article helps you. Please provide me with feedback on my article.
Opinions expressed by DZone contributors are their own.