Now, in this tutorial, we will discuss with Selenium and its components features, benefits, and difference between Selenium vs QTP.
What is Selenium?
Selenium is a free and open-source functional automation testing tool that is used to test the functionality of the web-based application. It is originally developed by Jason Huggins in 2004.
Basically, testing is mainly divided into two categories. First is Functional testing and second is Non-functional testing. In functional, we have two kinds of testing: Manual testing and Automation Testing.
In manual testing, our main activity is to write the test cases. These test cases will be executed manually by some resources but when coming to automation testing, all the manual test cases will be converted into the test scripts with the help of some automation tools like Selenium, QTP, RFT, etc.
Thus, the process of converting manual test cases to the test scripts with the help of some automation tool is called automation testing. The main advantage of using these tools is that we can save time.
Why should we use Selenium?
Selenium can be used as an automation testing tool due to many technical reasons. Some of them are as follows:
1. Ease implementation and Usage: Selenium tool is very easy to implement and in use. It has a very nice user interface and can be easily integrated with other popular IDEs such as Eclipse IDE, Spyder, Atom, NetBeans, and Microsoft Visual Studio, etc.
2. Free, open-source, and very popular: Selenium is a very popular and well-run open-source tool. It can be freely downloaded. Selenium is well supported and maintained by a very big supporting community.
3. Reusable and extensible framework: Selenium was extended progressively as Selenium Core > Selenium RC > Selenium Grid > Selenium WebDriver. Being an open-source tool, talented developers contribute to developing solid features in the Selenium framework that makes highly reusable and largely compatible across different platforms.
Selenium is easy to integrate with various other tools such as Cucumber and behavior-driven development (BDD) and gives the flexibility to select the tools for the testing team.
4. Easy to learn and use: Selenium is a good automation tool for testers. It uses the basic features of popular programming languages like Java, Python, C#, PHP, Perl, and Ruby. It also provides a library of functions that are easy to understand and use. It does not use very complex functions and concepts that make it difficult in learning for beginners.
5. Set of Jar files: Selenium suite needs a set of Jar files that serves as automation tools for the purpose of testers. It does not require a heavy server footprint or a client machine configuration.
6. Multi-platform/multi-device support: Just like Java, Selenium supports multiple operating systems such as Windows, Unix, Macintosh OS, as well as Linux.
Selenium toolkit can be run across any platform or device as well. The test script written once in one operating system can be used across any other OS platform.
7. Multi-browser support: With the creation of the WebDriver tool, Selenium is enabled with several features that allow testing of web application across multiple browsers. New versions of web browser get supported easily with Selenium suite.
8. Concurrent execution: With the evolution of Selenium grid and Webdriver, automation testers can run multiple scripts in parallel across different browsers, operating systems, and devices to finish testing quickly. Parallel (concurrent) execution helps to reduce overall testing time.
There are four components available in selenium suite to automate the web application. These components are shown in the below figure.
Let us briefly take a look at the components of selenium.
2. It is an easy-to-use Firefox plugin that supports the only Mozilla Firefox. It does not support any other browser like chrome, internet explorer.
3. It is used to create and edit test cases and test suite.
4. Selenium IDE supports a very simple record and play back feature for generating and executing the test scripts in the Firefox browser.
Let’s take one realtime example to understand the concept of recording and play back.
Suppose you have a mobile. In the mobile, you have an option like audio recording features. How will you record your voice for 1 min? For recording, you will put your mobile in the audio recording mode and start to speak something for one minute. When one minute is completed, you will playback it to check the recording.
The same kind of actions occurs in the Selenium IDE. In the Selenium IDE, we record our test cases like logging, send an email, compose, register, etc depending on the applications. Once the recording is completed, we can playback to execute them.
If required, we can also execute in other browsers with the help of Selenium RC and WebDriver. By default, it will record in the HTML language only but you can convert the recorded language into other languages also.
Selenium IDE is accountable for user actions. That means whatever actions you are performing like opening URL, clicking on some button, selection value from the drop-down, etc All these actions are recorded and generated into the scripts.
Initially, it will give you in the HTML language. After recording, It is played-back again and again to reperform those actions. Recording, as well as execution, can be done in the Firefox only.
1. Selenium RC stands for Selenium Remote Control. It is also known as Selenium 1.0. It is open-source automated testing software to test web-based application. It was designed by Paul Hammant.
3. In 2007-08, Test Automation Engineer could be able to control and automate the entire application by using Selenium RC. He can perform the actions like clicking on a button, entering text into a TextBox, selecting the value from drop-down box, etc.
Selenium RC has the ability to test the whole functionality of web application. That’s a reason that the given name with the selenium is remote control.
4. Selenium RC requires a server to be started before the execution of test script. A server is responsible to serve your request in the Selenium RC.
For example, suppose you have a Gmail account. You have entered a user id and password. After entering credentials, it will send your request to the server and the server will send your request to the data base.
Then the server will take the response from that database and the response will be given back to the application. Look at the below figure to understand better.
Whatever test cases we create, these test cases are converted into the test script. After that, the test script is compiled and ran against the selenium server (Selenium RC).
7. It does not support record and playback feature.
1. Selenium WebDriver is a latest, free, and open-source library to automate the web application. It is a pure object-oriented tool.
2. In 2008, Selenium RC was merged with another testing framework called WebDriver to develop a more powerful tool called Selenium 2. That’s why it is called Selenium WebDriver. Simon Stewart was the creator of Selenium WebDriver.
3. Selenium WebDriver was developed to support dynamic web pages and advanced web application testing. Selenium 2.0 was released in July 2011.
4. The main aim of Selenium WebDriver is to automate the web application and make sure that the website is working as expected. It contains a variety of classes and methods to meet our requirements.
5. It supports different programming languages such as Java, Ruby, Perl, PHP, Python, and .Net to create the test scripts.
6. It supports different browsers like Firefox, Chrome, Internet Explorer, Safari, etc.
1. Selenium grid was developed by Dan Fabulich and Nelson Sproul with the help of Patrick Lightbody in 2005 to minimize the test execution times as much as possible.
2. It provides a cross-browser testing environment with several different browsers (such as Firefox, Google Chrome, Internet Explorer, etc) and different platforms (Window, Mac, and Linux) to execute a test.
3. Selenium grid uses the hub-and-nodes concept. The hub acts as a central point which has the information of all different testing platform, known as nodes. All nodes are connected to a hub that enables simultaneous execution of tests in multiple browsers.
4. Selenium Grid provides parallel execution of tests to save a lot of time. Let’s take an example to understand how Selenium grid can save a lot of time.
Suppose we have automated 100 scripts in 2 hours by using WebDriver in the Firefox browser. Now my plan is to run all these 100 scripts in different browsers such as internet explorer, firefox, and chrome.
Suppose each browser is taking 2 hours to execute all 100 test scripts. So, all three browsers will take time 6 hours to execute.
If we use selenium grid to automate 100 scripts, we can execute all 100 test scripts in parallel on all three browsers. Thus, the main advantage of using selenium grid is that we can launch all browsers parallelly at the same time and the script can be executed in all browsers at the same time.
Thus, we can save time. We can use total of 5 browsers by using the grid.
Remote Control was completely removed from Selenium 3 version. Now Selenium 3 version consists of IDE, WebDriver, and Grid. A new revised version of Selenium IDE that supports both Chrome and Firefox browser, was released in August 2018.
At present, Selenium project team is working on a new version of Selenium 4, and the alpha version was released in April 2019.
1. Selendroid is one of the best and most powerful testing tools for android application. It is an automation testing framework to test multiple types of mobile applications like native, hybrid, and web.
2. Since Selendroid uses the Selenium WebDriver framework so we can write the test scripts using the Selenium 2 client APIs.
3. Using the Selendroid, you can also run tests in parallel on multiple devices.
Let us understand it with a realtime example. Suppose we have a Gmail web application and have tested on my system. Now we want to test the same Gmail web application on android mobile. So, this test can be performed by using Selendroid to test the web application on the android device.
1. Appium is an open-source mobile automation framework which is used to test native, hybrid, and web mobile application on iOS and android operating system with the help of Selenium WebDriver.
2. It replaces Android driver and iPhone driver APIs in the selenium 2 that were used for testing mobile application.
4. Using Appium automation framework, we can perform cross-platform mobile application testing.
How to choose the Right Selenium Tool for your need?
You do not need to learn all the above selenium tools but knowing the basics of each component will be helpful and it will boost your confidence in selenium.
Generally, we have to work with the most powerful tool WebDriver because WebDriver is the main driving tool to automate user actions on different browsers and operating systems.
Each browser provides its own driver such as Firefox driver, Chrome driver, etc to automate actions. If you have enough number of tests to automate and want to run all tests in parallel then you may use Selenium Grid to run your tests on different browsers in parallel.
Selendroid and Appium are used for testing mobile web application. As far as learning is concerned, You can learn WebDriver, selenium grid, Selendroid, and Appium. You do not need to learn selenium 1 in order to learn selenium 2 or 3.
What are the benefits of Selenium?
The highlighted benefits of Selenium are as follows:
1. The main benefit of choosing Selenium is that it saves costs in terms of manual test effort reduction and removal of defects quickly.
2. The code and framework can be reused. Once the test script is ready, can be reused multiple times.
3. Selenium supports parallel test execution with multiple data sets, devices, and platforms that saves time. Tests can be run automatically without dependency on humans.
4. It helps in finding defects early and fix them as well.
5. Since the automation test scripts follow the logic, therefore, manual errors such as mistyping, clicking wrong buttons, or other types of errors can be avoided using test automation.
What are limitations of using Selenium?
We know that Selenium is a good tool for automation, but there are some limitations that must know before using Selenium for test automation. They are
1. Selenium supports the testing of only web applications. It does not support the testing of Windows applications, mobile applications, batch processes, etc.
2. Needs solid programming skills to do “meaningful and purposeful automation testing”.
3. The cost of automation maintenance could be high, if not coded efficiently.
4. CAPTCHA, reCAPTCHA, and bar-code readers cannot be automated using Selenium.
5. Selenium has neither any built-in object repository nor in-build features to read data from external sources like .xls, .csv, etc.
Difference between Selenium and QTP
The difference between selenium and QTP is explained in the below table.
|1. Selenium supports almost all popular browsers such as Firefox, Chrome, IE, Opera, etc.||1. QTP supports only Chrome, Firefox, and Internet Explorer browser.|
|2. Selenium supports operating system like Windows, Linux, and Mac.||2. QTP supports only the Windows operating system.|
|3. Free open source tool.||3. Licensed tool (Commercial tool)|
|4. It supports only testing of the web-based application.||4. It supports both web and windows based application.|
|5. Object repository needs to be created in the selenium.||5. QTP automatically creates and maintains object repository.|
|6. It supports multiple programming languages like C#, Java, Python, Ruby, Perl, etc.||6. It supports only VB script.|
|7. We can execute tests in parallel.||7. In case of QTP, we can execute tests in parallel only using Quality Center which is again paid product.|
Note: QTP stands for Quick Test Professional which is the product of Hewlett-Packard. It uses Visual Basic Scripting (VB Script) for automating web and windows based applications.
Hope that this tutorial has covered almost all the basic important points related to selenium and its components. I hope that you will have understood this topic and enjoyed it.
Thanks for reading!!!
Next ⇒ Selenium WebDriver Architecture⇐ PrevNext ⇒