Selenium is an open source testing tool which automates web browser actions. It provides tools that can interact with browser and can automate browser actions like click, input, select, navigate etc with the help of scripts. There are many testing tools available in the market like UFT, TestComplete etc. But now a days majority of people prefer Selenium as it is an open source Automation testing tool. You can download it for free. You need not pay to use this tool. This open source feature makes it one of the hottest tools in the market as everyone is looking to cut costs and keep the automation costs down to minimum.
If we take the example of Microfocus UFT formerly HP QTP, we need to pay a lot of money to use it commercially. However in the case of Selenium, all we need to do is go to Selenium official website, download the Selenium jar and start working.
It is used exclusively for Web based applications. For an example if you want to automate a desktop or a client server application or even a mainframe application, then Selenium is not the right tool for that. In order words, this is one of the limitations of Selenium that it cant automate desktop based applications. However, since majority of the projects are now web based, you will be able to automate majority of your applications.
One of the best advantages of Selenium is that it works on multiple Operating Systems. It is the only open source tool available in the market which supports both Windows & Mac OS. There is no other tool which has cross platform capabilities.
Platforms supported by Selenium
• Windows
• OS X
• Linux
• Solaris
Now there is a support for mobile automation. Appium as an extension of Selenium is used exclusively to test mobile applications in both Android & iOS platforms.
Selenium supports a variety of programming languages. You can write Selenium code in following languages:
• Java
• Python
• Perl
• Ruby
• C#
• PHP
You don’t have to be an expert in all. You just need to get proficient in one language and you are good to go. Most commonly used languages with Selenium are Java & Python. You may want to see a Quick comparison of Java vs Python here.
The most popular programming language used with Selenium is Java. One of the most commonly asked question is “I have developed my application with C#. Can I use Selenium with Java to automate C# based application?” The answer is Absolutely yes. The language that we use in your Automation code is completely independent of the language on which your application is built upon. So even if our application is built in Java, we can automate it with Selenium using Python as the programming language. We can use any of the programming language as it is independent from the language it is coded in.
One of the best features of using Selenium as an automation tool is the Multi-Browser support.
Selenium supports the following browsers:
1. Chrome
2. Mozilla Firefox
3. Internet Explorer
4. Safari
5. Opera
Source: https://www.seleniumhq.org/about/platforms.jsp
It is the only tool which supports cross-browser testing. In case of any other automation tools like UFT, it is not really consistent in automating multiple browsers. However, we get same stability in all different browsers.
So we have learnt in this Selenium Tutorial that we can work on multiple browsers, we can use multiple programming languages apart from being an open-source tool. Because of these capabilities it is one of the most commonly used automation tools in the market right now. Because of these flexibilities, majority of people now don’t give a second thought about Selenium as there is no question of license and getting it renewed.
One of the drawbacks of Selenium is that as it is a free tool, there is no dedicated technical support which is available in other paid tools like UFT.
Components of Selenium
1. Selenium IDE is a record and playback plugin for Firefox & Chrome browsers. We can use it for prototype testing.
2. Selenium Remote Control(RC) is also known as Selenium 1 is used to execute scripts using Javascript. At this moment, it is not actively supported.
3. Selenium WebDriver is the most active component today for frameworks and it is an API used to interact directly with the browser.
4. Selenium Grid is used to provide us the capability of running tests in parallel across different machines and browsers simultaneously and it saves time enormously.
Who created Selenium?
In 2004, Selenium was created by Jason Huggins who was an engineer at Thoughtworks(Chicago).
He was working on a web application which was required to be tested frequently and it was hard to manage it. After realizing that Manual testing is so hard and time consuming, he created a Javascript program that can automatically control the browser actions. He called it “Javascript Test Runner”.
He started giving demos to his team internally within Thoughtworks and soon came an idea to make it open source as a reusable Software Testing framework. Later he renamed it to Selenium Core.
Afterwards, soon came a new problem known as “Same Origin Policy Issue”.
Same Origin Policy Issue
According to this policy, Javascript within the same domain can access all the webpages. However, it can not access any webpage outside the domain because of security reasons. Example if there is a javascript xyz.js present on google home page. As per Same Origin Policy, this javascript can access all internal google pages like google.com/adsense, google.com/sheets. However, it wont be able to access any outside domain for example softwaretestinggenius.com or even yahoo.
This is the reason that before Selenium Remote Control(RC) came to existence, automation testers had to keep both the Selenium Core(javascript program) and the web server having the web application locally on the same machine so that everything belongs to the same domain.
How Selenium Core came into picture?
Because of the restriction imposed by the Same Origin Policy, automation testers had to keep the web server containing the web application and the Selenium Code together on the local machine. To overcome this issue, another engineer from Thoughtworks started working to counter this issue. The result was a server that will act as an HTTP proxy which will trick the browser to believe that the Selenium Core and the web application being tested are hosted on the same domain. He called it Selenium Remote Control(RC) or Selenium 1.
After came Selenium Grid
Patrick Lightbody was another engineer at Thoughtworks who was involved in the same project who created Selenium Grid so that we can reduce the test execution time as much as possible. Initially, he called it “Hosted QA” which could capture the browser screenshots at particular intervals as well as sending Selenium commands to different machines simultaneously. He was also responsible for making Selenium RC stable for large scale deployment.
Selenium was made open source and released at the end of year 2004.
In 2006, the enhanced Selenium Remote Control took over Selenium Core completely and was released as Selenium 1.
Then came Selenium IDE – For Record & Playback & prototyping tests
A Japanese guy, Shinya Kasatani created Selenium Integrated Development Environment(IDE), which was a Firefox extension for recording & playback in Firefox browser so that we can create simple test cases at a great speed. In 2006, he donated Selenium IDE to the Selenium project team. At this moment, Selenium IDE now supports Chrome browser as well.
Then WebDriver Came into Existence in 2007
In 2007, another Thoughtworks engineer started working on a project to create another testing tool to overcome some limitations of Selenium 1. He named it WebDriver. In Selenium 1, we always required a Web server to interact with the web browser. However, in Webdriver, this limitation as removed. It was considered as the 1st cross platform testing framework which could control the browser from OS level.
How Selenium 2 was Born
In July 8, 2011, Selenium 1 and WebDriver were merged to form Selenium 2.0 and an official announcement was made by Selenium blog https://seleniumhw.wordpress.com.
Selenium 3 – The latest version
It was released in October 2016, Selenium Remote Control(RC) is now being deprecated and its entire implementation is replaced with webdriver. You wont find Selenium Remote Control for download anymore from SeleniumHQ official website.
Selenium Releases History
Why Selenium Name?
While Selenium was in its early stages, there was a very popular paid tool named Mercury QTP now Microfocus UFT. Since Mercury is a poisonous compound, Jason Huggins cracked a joke that Selenium can be a good anti-dote for mercury poisoning. We can still see the after-effects of this anti-dote as Selenium has actually eaten quite a big share of UFT, formerly known as HP QTP.
Advantages & Disadvantages/Limitations of Selenium WebDriver
Pros:
1. It is an open source tool so anyone can download it and start in a short time.
2. It supports multiple programming languages like Java, C#, Python, Perl, Ruby, PHP.
3. It is platform independent which means it supports multiple OS like Windows, Mac, Linux& Solaris.
4. It can be used for cross browser testing across Firefox, Chrome, IE, Safari& Opera.
5. It supports headless browser.
6. It is easily integrated with open source frameworks like TestNG, JUnit.
7. It can be easily integrated with CI-CD process for example Jenkins, Maven.
8. It supports parallel test execution along with Selenium Grid.
9. It supports testing AJAX functionalities and helps in monitoring changes in content without loading the page.
10. The browser interaction is realistic.
Cons:
1. It supports only web based applications. There is no support for windows applications.
2. There is no official support or help for WebDriver.
3. We can not automate scenarios like barcode, captcha etc.
4. You need to learn programming.
5. It has no inbuilt mechanism for generating reports.
An expert on R&D, Online Training and Publishing. He is M.Tech. (Honours) and is a part of the STG team since inception.