【 Note 】 This article is translated from: www.edureka.co/blog/what-i… Do you know what Selenium is? Do you know why you use it? The answer is in this article, and I’m glad to be here with you. Automated testing is taking the world by storm, and Selenium certification is one of the most sought-after skills in the industry.

What is Selenium?

Selenium is an open source tool for performing automated testing on a Web browser (Web application testing using any Web browser). Wait, before you get too excited, let me reiterate that Selenium can only test Web applications. We cannot use Selenium to test any desktop (software) applications, nor any mobile applications. That’s bad, right? I feel your pain. But rest assured, there are many tools for testing desktop software and mobile applications, for example: IBM’s RFT, HP’s QPT, Appium, and more. However, this article focuses on testing dynamic Web applications and why Selenium is the best at it.

What are the advantages of Selenium?

Because Selenium is open source, it does not involve licensing fees, a major advantage over other testing tools. Other reasons for Selenium’s growing popularity are:

  • Test scripts can be written in any of the following programming languages: Java, Python, C#, PHP, Ruby, Perl, and.net
  • You can test on any of the following operating systems: Windows, Mac, or Linux
  • You can test using any browser: Mozilla Firefox, Internet Explorer, Google Chrome, Safari, or Opera
  • You can integrate with tools such as TestNG and JUnit to manage test cases and generate reports
  • Can integrate with Maven, Jenkins, and Docker for continuous testing

But there’s always a downside, right?

  • We can only use Selenium to test Web applications. We cannot test desktop applications or any other software
  • There is no warranty support for Selenium. We need to leverage our existing customer community
  • Unable to test the image. We need to integrate Selenium with Sikuli for image-based testing
  • There is no native reporting tool. But we can solve this problem by integrating it with frameworks like TestNG or JUnit

First, let’s take a look at how Selenium has grown to where it is today. So, let’s go through it in the following order:

  1. Software testing appeals
  2. Manual testing challenges
  3. How does automated testing beat manual testing?
  4. How does Selenium compare to other testing tools?
  5. Selenium Suite tools

Software testing needs

It all boils down to software testing. Today’s technological world is entirely controlled by machines, whose behavior is controlled by the software that drives it. Will the machines behave exactly as we want them to? Does every occasion live up to expectations? The answers to these questions lie in software testing. Ultimately, the success rate of your software application will control your business growth. The same can be said even for Web applications, since most businesses today are completely dependent on the Internet. Take any e-commerce company. Whether it’s Amazon or E-Bay or Flipkart, they all depend on customer traffic on their websites and business traffic on their Web-based mobile applications. Imagine a catastrophic event, such as limiting the price of many products to $10, due to a small error in the “not so easy to understand” part of the code. So what do we do? How do we prevent it next time? Test the code before deploying, right? So, that’s what software testing is all about. But what is Selenium? Is it a software testing tool? Well, Selenium is an automated testing tool! Before going any further, let me clarify that there are two types of software testing: manual testing and automated testing. Selenium was created as an automated testing tool to overcome the drawbacks/limitations of manual testing. So, let’s look at the challenges of manual testing.

Manual testing challenges

Manual testing is when QA testers manually test (Web) applications. Tests need to be performed manually in each environment with different data sets, and the success/failure rate of each transaction should be recorded.Look at this awful guy in the picture above, who manually verifies recorded transactions. The challenges he is facing lead to fatigue, boredom, work delays, errors and errors (due to manual manipulation). This led to the invention of Selenium, an automated testing tool.

Automated testing trumps manual testing

Every automated test beats manual testing. Why is that? Because it is faster and requires less investment in human resources, it is less error-prone, can perform tests frequently, supports unattended execution, regression testing, and functional testing. Let’s take an example similar to the one mentioned earlier. Assuming we have a login page and we need to verify that all login attempts are successful, it is easy to write a piece of code to verify that all transaction/login attempts are successful (automatic test case execution). In addition, these tests can be configured in the same way that they are tested in different environments and Web browsers. What else can we do? You can automatically generate result files by scheduling specific times of the day. You can then automatically generate reports based on these results. The point is that automated testing makes the tester’s job much easier. The figure below shows a more relaxed environment with the same testers at work.Now, let me talk specifically about Selenium. Let’s take a look at Selenium’s position in the market.

Selenium compares QTP and RFT

I compare its performance to two other popular tools: QTP and RFT in the table below.

features HP QTP IBM RFT Selenium
authorization Need to be Need to be Open source
cost high high Open source
Software Customer Support HP Proprietary Support IBM Proprietary Support The open source community
Hardware consumption during script execution high high low
Coding experience Don’t need Need to be Adequate coding skills and experience are required
The environment to support Only supports Windows Only supports Windows Windows, Linux, Solaris OS X (if browser and JVM or JavaScript support exist)
Language support VB Script Java and c # Java, C#, Ruby, Python, Perl, PHP, and JavaScript

It is clear from the table above that Selenium is the most favored tool. But there are many different styles in Selenium, and you should know which Selenium tool is best for your needs.

Selenium Tool Suite

  • Selenium RC (now obsolete)
  • Selenium IDE
  • Selenium Grid
  • Selenium WebDriver

What are the components of Selenium?

I explain the various components of Selenium in detail below:

Selenium RC (Remote Control)

Before getting into the details of Selenium RC, I want to come back to the first tool in the Selenium project. Selenium Core is the first tool. However, Selenium Core has encountered obstacles in cross-domain testing due to the same origin policy. The same-origin policy prevents JavaScript code from accessing Web elements hosted on domains different from where JavaScript was launched. To overcome the same-origin policy problem, the tester needs to install Selenium Core (a JavaScript program) and a local copy of the Web server that contains the Web application to be tested so that they belong to the same domain. This led to Selenium RC, which ThoughtWork engineer Paul Hammant endorsed at the time. RC solves this problem by using an HTTP proxy server to “trick” the browser into believing that Selenium Core and the Web application under test are from the same domain. Therefore, make RC a two-component tool.

  1. Selenium RC server
  2. Selenium RC Client – a library containing programming language code

RC Server communicates using simple HTTP GET/POST requests. See the following figure for an overview of the RC architecture.The flagship tool for the Selenium project is Selenium RC, their first tool that can be used to write test cases in different programming languages. But the downside of RC is that every communication with the RC server is time consuming, so RC is very slow. It’s too slow, sometimes taking hours at a time. As of Selenium V3, RC has been deprecated and moved to legacy packages. You can still download and use RC, but unfortunately it is no longer supported. But on the other hand, why use an outdated tool, especially when there is a more effective tool called Selenium WebDriver. Before talking about WebDriver, let me discuss IDE and Grid, which are the other tools that make up Selenium V1.

Selenium IDE (Integrated Development Environment)

In 2006, Shinya Kastani of Japan donated his prototype Selenium IDE to the Apache Selenium Project. This is a Firefox plug-in for quickly creating test cases. The IDE implements a record and playback model in which test cases are created by recording user interactions with the Web browser. These tests can then be played any number of times. The advantage of Selenium IDE is that tests recorded by plug-ins can be exported in different programming languages, such as Java, Ruby, Python, etc. See the screen capture of the Firefox IDE plug-in below.However, the related disadvantages of ides are:

  • The plugin is only available for Mozilla Firefox; Does not work with other browsers
  • Dynamic Web applications cannot be tested. Only simple tests can be recorded
  • Test cases cannot be scripted using programming logic
  • Data-driven testing is not supported

These are some aspects of Selenium IDE. Now let me talk about Selenium Grid.

What is Selenium Grid

Selenium Grid, developed by Patrick Lightbody and originally called HostedQA (originally part of Selenium V1), is used in conjunction with RC to run tests on remote computers. In fact, using Grid makes it possible to execute multiple test scripts simultaneously on multiple machines. Implement parallel execution with the help of hub-Node architecture. One machine will act as a hub, while the others will act as nodes. The hub controls test scripts that run on a variety of browsers within a variety of operating systems. Test scripts executed on different nodes can be written in different programming languages.Grid is still in use and can be used with WebDriver and RC. However, maintaining the grid with all the required browsers and operating systems is a challenge. To that end, there are several online platforms that provide online Selenium Grids that you can access to run Selenium automation scripts. For example, you can use LambdaTest. It has more than 2000 browser environments in which you can run tests and truly automate cross-browser testing.

What is Selenium WebDriver

Founded in 2006 by Simon Stewart, Selenium WebDriver is the first cross-platform testing framework that allows you to control browsers from the operating system level. In contrast to an IDE, Selenium WebDriver provides a programming interface to create and execute test cases. Write test cases to identify Web elements on a Web page and then perform actions on those elements. WebDriver is an upgrade to RC because it is faster. It’s faster because it calls the browser directly. RC, on the other hand, requires the RC server to interact with the Web browser. Each browser has its own driver on which applications can run. The different WebDrivers are:

  • Firefox Driver (Gecko Driver)
  • Chrome Driver
  • Internet Explorer Driver
  • Opera Driver
  • Safari Driver and
  • HTM Unit Driver

Benefits of Selenium WebDriver

  • Supports 7 programming languages: JAVA, C#, PHP, Ruby, Perl, Python, and.net
  • Supports testing in different browsers, such as Firefox, Chrome, Internet Explorer, and Safari
  • You can run tests on different operating systems, such as Windows, Mac, Linux, Android, and iOS
  • Overcome limitations of Selenium V1, such as file uploads, downloads, pop-ups, and dialog bars

Disadvantages of Selenium WebDriver

  • Unable to generate detailed test reports
  • Unable to test image

Whatever the tightening challenges, these shortcomings can be overcome by integrating with other frameworks. Sikuli can be used for test images, and TestNG can be used for generating detailed test reports.