DEV Community

Cover image for Everything to Know about Selenium and its Role in Test Automation
Morris
Morris

Posted on

Everything to Know about Selenium and its Role in Test Automation

Selenium is a testing environment and framework that, simply put, lets you automate browsers. This is great for creating test environments where your application and its resource utilization can be tested across real world user stories.

What is Selenium

From their website,
“Selenium automates browsers”
It’s an automation testing tool that will automate your web-based application and it works on the following browsers i.e. Chrome, Internet Explorer, Firefox, Opera, and Safari. This makes selenium very powerful because it works on multiple browsers, browser versions and a wide array of Operating Systems. This makes it a very powerful tool and that’s why the demand for selenium is increasing since its inception.
One writes code for Selenium in

  • C#
  • Java
  • Ruby
  • Python
  • Perl
  • PHP These are the six languages that Selenium supports now. It’s not necessary that if your application under scrutiny is made in PHP, then you would have to write your Selenium test cases in PHP, or in Java for a Java-based app. You can make your website in C# and can write your selenium code in PHP as well. So it is independent of the language in which the website is made. Selenium supports multiple browsers, and multiple operating systems, and multiple languages. The Suite is made up of four components, or rather, it evolved in 4 stages –

Selenium IDE

IDE is something that comes as an add-on in Firefox, it only works on the Mozilla browser and comes as an add-on in the Mozilla Firefox. IDE is primarily a record and run tool. Since Recording and running functionality is present in every automation tool, it is present in IDE as well. The main drawback of IDE is that it works only on Mozilla Firefox.

Selenium RC

Earlier there was something known as RC which used to work on multiple browsers and it is available in multiple languages as well. You can write the test code in Java, C#, Ruby, Python Perl or PHP for learning IDE. You don’t need to learn any programming language, but if you are working with RC you must know any one of the programming languages. RC had its own limitations as well. With RC there used to be a separate server which was difficult to handle.

Webdriver

So to overcome those limitations Webdriver came into existence. Webdriver supports multiple browsers. It is an enhanced version of RC, but the architecture of webdriver is completely different from the architecture of RC. IDE only works only on Mozilla but RC and webdriver works on all the browsers and both of them require the knowledge of any one of the programming languages from above.
Read more : A comprehensive guide on Selenium Webdriver

Grid

The grid is something that will help you run your test cases parallelly. For example, let’s say you’ve got 200 test cases, and you want to run the test cases parallelly on three machines. One machine can handle test case execution on Safari, the other will run it on Mozilla, and the next one on the Chrome. Say you want to distribute your test cases on four different machines that are on the first machine. The first 50 test cases should run on the next machine. Next 50 on the third, Next 50, and on the fourth etc. You want to divide your test cases into two parts and run them parallely. This way, execution takes lesser time.

To summarize, The entire Selenium Suite is comprised of four components. IDE, a Firefox add-on that you can only use in creating relatively simple test cases and test suites.
Selenium Remote Control, also known as Selenium 1, is the first of our tools that allowed users to use programming languages in creating complex tests.
WebDriver, the newer breakthrough that allows your test scripts to communicate directly to the browser, thereby controlling it from the OS level.
Selenium Grid is also a tool that is used with Selenium RC to execute parallel tests across different browsers and operating systems.
Selenium RC and WebDriver were merged to form Selenium 2. It is more advantageous than QTP in terms of costs and flexibility. It also allows you to run tests in parallel, unlike in QTP where you are only allowed to run tests sequentially.
This blog is originally published at TestGrid

Top comments (0)