- Posted by Neeraj Maurya
- On July 29, 2019
- what is selenium
The first question that comes to mind when you see the word Selenium is:
What is Selenium and what are it’s uses?
Therefore, through this blog we will try to cover all aspects of Selenium. After reading the whole blog, you will be able to know the fact that what lies at the core of your next job role if you are enthusiastic to learn Automation testing method using Selenium.
Right now, it has taken over the traditional quality assurance methodologies in IT industries worldwide and has set a benchmark in terms of Quality Assurances because it is fully automated and one of the most demanded expertise that is required in the industry is “Selenium Certification”.
What is Selenium?
For starters, Selenium is an open-source tool available to automate the required tests to be carried out on the existing web-based browsers. (In simpler words, it tests the web applications by using any web-based browsers like Google Chrome, Mozilla Firefox, Opera Browser, Internet Explorer, MS Edge etc.)
Now, before you start exploring your imagination, let me clear something very important about Selenium i.e. you can only test the web applications using Selenium and it is not used to test either the software (desktop applications) or any mobile-based applications. This can also be considered as one of the drawbacks of Selenium that we will discuss later.
The good thing is that you can automate the testing of software and mobile applications by using the other available tools like: RFT from IBM, QPT by HP, Appium etc.
This blog is also focused on the testing and quality analysis of the dynamic web applications and the reasons that makes the Selenium the best solution to achieve/fulfil this purpose.
Well first thing first. We discussed above that Selenium is open-source, which means that you don’t need to pay for the licensing in order to use this tool and this is one of the main and major reason for the popularity of this trend in Automation Testing. The other benefits and advantages of use of Selenium are as follows:
- The Quality Analyst can use any of these programming platforms to write the test scripts: C#, PHP, .NET, Java, Python, Ruby & Perl.
- You can carry out the test on not just one operating system but also on Windows, Mac or Linux as well.
- You can use different browsers to perform the tasks: Mozilla Firefox, Google Chrome, Internet Explorer, Opera and Safari.
- The tools like TestNG and Junit can be integrated with Selenium to generate the reports and to manage the test cases.
- Maven, Jenkins & Docker can also be integrated with Selenium to perform continuous Testing.
- By now you must be thinking if Selenium is so perfect that there are no limitations or disadvantages or shortcomings with this approach. So here is answer to your confusion. Below are the drawbacks with Selenium:
- The first and foremost in this category is the fact that you can use Selenium to test the web applications only and not to test the desktop applications or any other software.
- At present there is no dedicated product support for the users of Selenium. They have to rely upon the online user communities to share the issues with it or to find solutions regarding the same.
- If you want to test an image via Selenium, you will be disappointed. In order to achieve image based testing, you will first have to integrate Selenium with Sikuli (for detailed info about Sikuli, you can go to this link: https://economictimes.indiatimes.com/definition/sikuli-tool)
- Selenium is not equipped with the native reporting facility but if that is required necessarily then you can integrate the Selenium with TestNG or JUnit to solve this issue.
Before we head further, I think we should first know that why the Selenium was required at first place or why Selenium became what Selenium is today. So join the journey in the following order:
- The requirement for Software Testing
- Manual testing limitations
- Automation testing is better than manual testing?
- Selenium v/s other available testing tools
- Selenium suite of tools
Requirement for Software Testing
Software testing is where everything sums up in the end. We are living in a world where our lives are totally depending on the machines one way or another and the interesting part is that the overall behavior of these machines is controlled and manipulated by the software that are empowering these machines or tools. This is where Software testing comes into the picture which verifies if the machines are acting exactly as we want them to act and also verifies if machine is working properly each and every time and everywhere as well.
No matter what you do as a service provider, your business growth in the end will be controlled by success rate of your software application and web application because the majority of today’s businesses are depending completely on the internet.
Let me give you an example. The big e-commerce company like Flipkart or be it Myntra, they depends on traffic of users or their customers on their web sites and also the traffic of the same people on their mobile based applications regarding the same purpose. Now imagine if something unthinkable happens like prices of all products are zero and it happened because of a small bug/defect in such a part of the code that is not very easy to read then how the situation will be rectified and how the same situation will be prevented from the next time?
The simplest answer is: By testing the code before the deployment and that’s the requirement of testing the software as well.
Now, let me clear something before we discuss anything further that there are two ways to accomplish software testing: Manually and via Automation. Selenium was designed as an automation tool to cover the areas that were not possible to cover with the manual testing so the next part of this blog will discuss the limitations of manual testing.
Manual testing limitations
The manual testing refers to the process of testing the web applications by looking and using the functions and features of a web application as an end-user and then make sure if the application is useful and working as per the requirement. In this method, a QA tester conducts all the tests on the software/application by following the pre-defined sets of test cases and also maintains the records of all the success or failure rates of all these transactions.
The challenges that a QA tester while manually verifying the recorded transactions can cause fatigue, boredom, unnecessary delay in work, mistakes and errors due to manual approach etc.
That’s why these reasons resulted in the invention of Selenium we know today.
Automation testing is better than manual testing?
Automation testing is always a better choice than manual testing. The reason is pretty simple. This approach is faster, requires low investment in putting human resources for one single task as compared to the manual approach, to execute the same test cases over and over again in bulk is way easier, it makes regression testing and functional testing more effective and it is most preferred approach to detect errors/bugs.
Let me try to explain it a bit more with the help of an example. Suppose I am testing the login page of an application (web application) to verify if all the attempts to login to check-in into the main page were successful then if I am testing it manually then I will have to check the records by always going to the sign-in page and try the same procedure over and over again and it can be really stressful and tiring but if I am doing the same thing via Selenium then I will take some time to write a test script that will validate if all the login attempt transactions were successful or not.
On the top of that, all these tests can be performed in such a way that before releasing the product to use, it can be confirmed that the product/web application supports different environments and web browsers as well. Now the next question arises that what else can we achieve using Selenium? Well the answer is that you can not only automate your testing but you can also automate the production/generation of result files and you can schedule it as well for a particular time of any given day.
This can be concluded easily that all these features of Selenium makes a tester’s duties a whole lot easier than it once used to be till Selenium was not popular.
Selenium v/s other available testing tools
Now let us have a look at where Selenium stands in the market.
To do that, I have tried to compare the performance of Selenium with two other popular tools that are available in the market: QTP (From HP) and RFT (From IBM) in the table below.
|Characteristics RFT (IBM)||RFT (IBM)||QTP (HP)||SELENIUM|
|Pricing||High||High||Open Source tool|
|Customer Support||Dedicated Support from IBM||Dedicated support from HP||Open Source Community|
|Hardware use during test script Execution||High||High||Low|
|Code Writing Skills||Necessary||Not necessary||Proper code writing knowledge and experience is a must|
The above comparison must have given you a clear picture that why most people prefer Selenium over any other tool (For Quality Analysis). Selenium has many components and before choosing one, first you should know that which one is perfect to fulfil your requirements.
Selenium Suite of Tools
Selenium is made of different software tools and each tool/component has a specific role.
- Selenium RC (Now depreciated)
- Selenium IDE
- Selenium Grid
- Selenium WebDriver
Selenium RC (Remote Control)
I think I should first discuss about the first tool of Selenium project before talking about Selenium RC and that tool was ‘Selenium Core’. But the same origin policy was the biggest issue with Selenium Core whenever the cross-domain testing was required.
To solve the issue of same origin policy, the QA members had to install the local copies of both Selenium Core and the web server where the web application is supposed to be tested so that they could belong to the same domain. That was the reason for the existence of Selenium RC we know today and is certified by Paul Hammant who was an engineer at ThoughtWork at that time.
To solve the issue with same origin policy, the QA members used to install local copies of both the Selenium Core and the web server on which the web application is under testing in order to belong to the same domain. That’s the reason why the Selenium RC came into the existence which is validated by Paul Hammant who was the engineer at ThoughWork at that time.
Selenium RC ruled out the issue by using a proxy HTTP server in such a way that browser behaved as the Selenium Core and the web application that was under testing were from the same domain and this is the reason why RC is also known as a bi-component tool namely:
- Selenium RC Server- (It communicates via simple HTTP GET/ POST requests)
- Selenium RC Client – (It is a library that contains the code of your programming language)
The crown jewel of the project Selenium was Selenium RC because of two main reasons a) Selenium RC was their first tool, and b) It had the ability to write test scripts in multiple programming platforms. But the issue with RC was that each transaction with its server was very time consuming which makes it a slow tool as well. It has also been observed that in many cases it takes hours to accomplish just a single test case.
RC is being deprecated since the release of Selenium V3 and had moved to the legacy package. However, you can still download and use RC but you are not going to find the support for it anywhere. But on the bright side there is no point in using something which is outdated and is replaced with much advanced and efficient tool which is Selenium WebDriver.
Now before I discuss WebDriver with you, let me talk about the other tools that collectively formed the Selenium V1.
Selenium IDE (Integrated Development Environment)
Shinya Kastani from Japan, gave his Selenium IDE prototype to Apache’s project based on Selenium in 2006. It was a Firefox based plugin focused on faster creation of test cases. The vital feature of IDE was the ability of record and playback where test cases were created via recording the transactions between user and web browser. Later these tests were available to be played back n number of times.
One most important advantage with Selenium IDE is that you can export the tests that were created via using plugin in multiple languages like: Java, Python, and Ruby etc.
The known issues with IDE are:
- The plugin was available only for Mozilla Firefox
- You can only record simple tests and testing of dynamic web applications is not possible
- You cannot script the test cases using programming logics
- Data Driven testing is not supported by Selenium IDE
Patrick Lightbody developed Selenium Grid and initially called it HostedQA. He used it with RC to accomplish the testing on remote machines. It was initially a part of Selenium V1. The most important feature of Grid was its ability to run multiple test scripts on multiple machines at the same time.
The Hub-Node architecture is used to perform parallel execution. One machine is supposed to be acting as Hub and the other machine will be the Node where the role of Hub is to control different test scripts running on different browsers running on different Operating Systems.
Parallel execution is achieved with the help of Hub-Node architecture. One machine will assumed to be acting as Hub and the other machine will be assumed to be acting as the Nodes. Hub controls the test scripts running on various browsers inside various operating systems. We can write the scripts in different programming languages that are being executed in different Nodes.
Till this date, we use Grid with both RC and WebDriver although it is not an easy task to maintain a grid with all necessary operating systems and web browsers and to deal with the situation, various online platforms like “LambdaTest” are used as they provide online Selenium Grid that can be accessed to run and execute the automation script of Selenium. The LambdaTest acquires over 2000 browser friendly environments that can be used to verify and run the required tests to achieve the goal of automating the cross-browser testing.
In 2006, Simon Stewart founded Selenium WebDriver and was also the very first ever testing framework for the cross platform testing that was also able to control the web browsers at the OS level. Unlike IDE, it establishes a programming alliance to maintain and execute the test cases in such a way that the web elements on web pages were easy to identify and also to perform actions on such elements was also easier.
It can also be said about WebDriver that it is as upgrade to RC because apart from the fact that it is way much faster but also because it establishes the direct calls to the web browsers while RC can’t because it needs RC server to do the same task. We know that to run the applications, the browsers are equipped with their own drivers for example:
- Chrome Driver
- Safari Driver
- Internet Explorer Driver
- Firefox Driver or Gecko Driver
- Opera Driver and
- HTM Unit Driver
Merits of Selenium WebDriver
Below are some advantages / merits of using Selenium WebDriver:
- Able to perform cross browser testing as it supports browsers like: Firefox, Chrome, IE etc.
- Able to perform tests on multiple operating systems as Windows, Mac, Linux, Android, iOS etc.
- Compatible with 7 different programming platforms like JAVA, PHP, Ruby, Perl, Python, C# and .Net.
- Resolved the issues with Selenium V1 like dialogs barrier, pop-ups, file download, file upload etc.
Demerits of Selenium WebDriver
Below are the major challenges that were with Selenium WebDriver:
- Generating detailed test reports is exhausting and mostly impossible.
- You cannot test the images with Selenium WebDriver.
Although these challenges can be handled but in order to do that you need to integrate it with the other available frameworks like Skuli that is used to test the images and TestNG that is used to generate the test results/reports in a detailed form.