Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Components of the Selenium Automation Tool

DZone's Guide to

Components of the Selenium Automation Tool

Learn the basics and different parts of Selenium for test automation and its pros and cons.

· DevOps Zone ·
Free Resource

Easily enforce open source policies in real time and reduce MTTRs from six weeks to six seconds with the Sonatype Nexus Platform. See for yourself - Free Vulnerability Scanner. 

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 supports various programming languages such as Java, C#, PHP, JavaScript, Ruby, and Python. It is language-independent, which means it was developed using Java, and can be used with C#, Java, PHP, JavaScript, etc.

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

Selenium Webdriver and Selenium Grid are the most commonly used tools in the IT industry for the development of testing products. Selenium was developed as an internal project to test internal applications at ThoughtWorks, developed in client-side technology like JavaScript by Jason Huggins. It is also called Selenium Core/Selenium IDE. Jason Huggins tested various internal applications and gave demos to different colleagues. They were excited about the success of the first version.

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.

Refer to these links to learn more about Selenium.

Components of Selenium

Selenium IDE

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.

Selenium IDE supports its own scripting language called Selenese, which doesn't require any programming language or complex commands to execute test cases. It is based on JavaScript and is very easy to use. It doesn't have any kind of APIs or Library to work with because it doesn't need any programming language.

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

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 is also based on JavaScript. It doesn't have a Record/Playback feature.
  • 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.
  • It supports execution with asynchronous JavaScript- and XML- (AJAX) based applications as well.

Whenever we want to execute test cases, the Selenium server acts as a mediator/server which should be started manually. Whenever we develop a framework using the above programming languages, this code is sent to Selenium Server, which acts as a mediator/server which in turn converts the code to JavaScript and sends it to the browser. As the browser understands JavaScript, the browser executes the given test cases and returns the result back to the server or Selenium Server, and this server returns the result to the client.

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.

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.

Selenium Grid

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.

Automate open source governance at scale across the entire software supply chain with the Nexus Platform. Learn more.

Topics:
selenium ,test automation ,devops

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}