Automation Testing Selenium - A Step by Step Guide for Beginners

By Michael Warne 05-Dec-2022
Automation Testing Selenium - A Step by Step Guide for Beginners

Selenium Automation Testing - Different tools and how to use them

If you are a web developer, you must be familiar with Selenium. Selenium is an open-source (free) framework that allows automated testing. It supports web browser automation and gives an interface where developers can write test scripts.

Before Selenium, testing a web application sometimes took a few weeks to complete as it was done manually. With Selenium, you can conduct an automated test and ensure your web app is fully functional. While it may seem that Selenium is just one testing tool, it is actually a collection of multiple tools.

In this blog, we have discussed the different Selenium automation testing tools and how to use them. This training programme on automation testing with Selenium. Your career as an automated test engineer will advance as a result of this training. The best abilities required by the sector will be taught to you. Students learn how to use the WebDriver 2.0 tool in this course to test web-based applications.

What is Selenium Automation Testing?

Whenever a new web application was developed, it was tested through manual means to ensure its functioning. There were many problems with manual testing. Not only was it time-consuming, but it was also monotonous and not 100% accurate. It was Jason Huggins who had the idea to automate the testing process and make it more efficient. 

He developed the automated testing program called ‘JavaScripTestRunner,’ which was later renamed to become Selenium. While Huggins developed this, more engineers later added tools to Selenium, making it a collection of various testing tools. These include Paul Hammant (Selenium Remote Control), Patrick Lightbody (Selenium Grid), Shinya Kasatani (Selenium IDE), and Simon Stewart (WebDriver). 

Selenium has made the automation process efficient and quick. The only disadvantage is that it doesn’t work for mobile or desktop apps. 

Tools for Selenium Automation Testing

Now that you know what Selenium Automation Testing is, let us move on to various tools that can be used for testing. 

Selenium IDE

Developed by Shinya Kasatani in 2006, Selenium IDE (Integrated Development Environment) is used as a prototype tool. Essentially, it is a Firefox and Chrome plugin that logs the user interaction and writes code in various programming languages. The primary purpose of IDE was to create automation scripts quickly. 

A new version of Selenium IDE came out recently, as the old version became useless after Firefox got upgraded. The new version has many additional features, including reusability and debugging of test scripts and improvement in locator functionality.

Pros

  • Easy to install

  • Knowledge of DOM and HTML is enough to use Selenium IDE

  • Has support for extensions

  • Tests can be exported to use in other Selenium testing tools.

Cons

  • Only works for Chrome and Firefox

  • Can only create test prototypes

  • Speed is slower than other testing tools

Selenium Remote Control (RC)

Since Selenium is a JavaScript program, it follows the Same Origin Policy. This policy allows JavaScript code to access only the programs with the same domain as its launch domain. This created a problem for Selenium users as they had to ensure both Selenium Core and the web application share the same domain to conduct the test. 

To address this problem, Paul Hammant created Selenium Remote Control which makes the browser believe that the Selenium core and the web application to be tested have the same domain. Selenium RC is written in Java, but it also accommodates other languages. It can support Java, P HP , Python, Ruby, Perl, and C#.

Pros

  • Supports new browser

  • Is faster than IDE

  • Data-driven testing is possible

  • Cross-browser

  • Cross-platform

Cons

  • Installation is not easy

  • Slower than WebDriver

  • Programming knowledge is essential

  • API has confusing commands

  • Can show inconsistent results

 Talk to Our Counselor Today 

Selenium Grid

Selenium Grid was initially called Hosted QA and was developed by Patrick Lightbody. The idea behind creating a Selenium Grid was to minimize the execution time of a test. One of the best parts of it is that it can facilitate parallel execution. It can enable tests on different environments and browsers simultaneously, which allows it to save time. 

Pros

  • Supports several browsers

  • Support multiple operating systems

  • Fast execution

  • Support multiple languages

Cons

  • Requires qualified engineers

  • Can be costly

  • Poor scalability

Selenium WebDriver

Created by Simon Stewart, Selenium WebDriver was the first framework that allowed cross-platform testing by configuring the browsers at the OS level. It did so by directly interacting with the browser. The approach of WebDriver is more modern than Selenium IDE and Selenium RC, making it a better testing tool.

Pros

  • Installation is easier than Selenium RC

  • Interaction with the browser is native

  • Faster execution than both Selenium RC and IDE

  • Doesn’t require a separate part as in the case of Selenium RC

  • Supports multiple programming languages

  • Easy integration 

Cons 

  • The installation process is more complex than IDE

  • Must have programming knowledge

  • Cannot support new browsers instantly

Testing guide with different tools

As discussed above, there are several Selenium testing tools. Let us discuss the steps to use each of these tools.

Steps for automation testing using Selenium IDE

Selenium IDE has three stages. These include recording, playback, and saving. Following are the steps to use it for testing.

Step 1: Install Selenium IDE

Install Selenium IDE in your Firefox browser. To do this, open the browser and click on the menu. Choose add-ons and then find more add-ons. Write Selenium IDE and add it to the browser. 

Step 2: Create a test

Create your first test. For practice, you can create a dummy Facebook ID and password. 

Step 3: Recording

Open Selenium IDE in your browser and click on ‘Record a test’. Add the name of your project and the link to the webpage. Selenium IDE will go to that page as per the link. Once you add the link, the recording of the test begins. Use the web app as you want. 

You can pause the recording at any point. Once you stop recording, Selenium IDE converts your interactions into a script. 

Step 4: Save progress

You will find the option to save on the top right side of Selenium IDE. It is stored as a .side file. 

Step 5: Playback

You can play the recording to see if the web application is functioning properly. In the menu bar, click on ‘play’ to watch the recording. You can also see which commands were executed properly and the errors that may have happened.

Must Read: Top 20 Selenium Interview Questions and Answers

Steps for automation testing using Selenium Remote Control (RC)

Selenium RC has two components - Selenium server and client libraries. You can run an RC client by following these steps. 

Step 1: Use the command prompt to launch Selenium RC

Step 2: Create a ‘new project’ in eclipse. Add the project name. 

Step 3: Verify the rest of the details and click on ‘finish.’ 

Step 4: Create a new package in your project by right-clicking on the project and selecting ‘new’ and ‘package’.

Step 5: Create a new class in your package by right-clicking on the package you created in the last step and selecting ‘new’ and ‘class.’ 

Step 6: Add your code and execute it by clicking on ‘run.’

Steps for automation testing using Selenium Grid

To use Selenium Grid for testing, follow these steps.

Step 1: Install Selenium Grid. You should also have Java installed. 

Step 2: Use the command prompt to set up the Selenium Hub. Hub is responsible for routing JSON commands to the nodes. 

Step 3: Use the command prompt to start nodes. You can also configure them to match your requirements. 

Step 4: You can use the DesiredCapabilities and RemoteWebDriver objects to run your test.

using selenium grid, a tester can conduct parallel tests on multiple browsers and os. the test command passes from the hub to a node that matches the test requirements. upon receiving the infor mation, the node executes the command. 

Steps for automation testing using Selenium WebDriver

Selenium WebDriver’s architecture consists of the following.

  • Selenium test script

  • JSON Wire Protocol

  • Browsers

  • Browser drivers

Follow these steps to use Selenium WebDriver:

Step 1: Install the latest version of Java.

Step 2: Configure Eclipse and configure a workspace.

Step 3: Go to the Selenium official website and download Selenium WebDriver Java Client.

Step 4: Download the browser driver and configure WebDriver with Eclipse IDE. 

Step 5: Add a project 

Step 6: Create a test script and select ‘run’.

And that’s it. Selenium will execute the script, and you will see the results. 

Choosing the right tool for testing

Since there are 4 Selenium automation testing tools, it can be tricky to select which will suit your needs the best. 

Why use Selenium IDE?

  • When you have little programming knowledge

  • When you are using chrome or firefox for testing a web app

  • When you want to create simple test scripts

  • If you want to export test cases in different formats

Why use Selenium RC?

  • When you are using an expressive language

  • When you want to run tests in multiple browsers and environments

  • When you want to test your web application in a new browser

Why use a Selenium Grid?

  • When you want to run parallel tests in several browsers and OS

  • When you have limited time to execute the test

Why use Selenium WebDriver?

  • When you want customized test results

  • When you want to use a specific programming language

Selenium automation testing is a revolutionary testing technology. It transformed how web applications are tested and made the process more efficient and accurate. The four Selenium tools have their pros and cons. You can follow the above steps to execute a test with each of them.

Enquire Now

Associated Course

32 Hours
English
32 Hours
English
32 Hours
English
32 Hours
English
32 Hours
English
32 Hours
English
Michael Warne

Michael Warne is a tech blogger and IT Certification Trainer at Koenig Solutions. She has an experience of 5 years in the industry, and has worked for top-notch IT companies. She is an IT career consultant for students who pursue various types of IT certifications.