SELENIUM 101: Automation Made Easy!

Avradeep Bala
The Project Team
Published in
4 min readMay 13, 2020

Selenium is an open-source automated testing suite for validating web applications across different browsers and applications.

For all those who might be wondering, what testing a web application refers to...

By testing a web application, we can make sure that our web-based application is functioning properly and can be accepted by real-time end users. A web application should go through a series of validations to ensure the functionality, usability, accessibility, compatibility, performance, and security of the application.

Suppose you want to search some series on Netflix, the best is way is to google it and click on the first result on the page and then, search for ‘Tokyo Ghoul’. Now, let’s take a step back and think, what if we didn’t have to do anything by ourselves? What if our browser could cardinally do it all on its own? NOW WOULDN’T THAT BE SICK? That is an example of web automation and YOU, yes you, can do it too, using Selenium!

BUT...here comes the question. Why do we need Selenium? Here’s why! Let us look at another scenario.

Suppose we consider an e-banking website. If the makers of the web-site decide to alter the structure of the ‘Manage Biller’ feature of the Bill payments option, it is necessary to perform Regression Tests on the absolute as well as the relative URLs of the website to make sure that a change in one feature of the website does not have an effect on the other relative URLs. Now, when we consider that for an official banking website, that can amount to THOUSANDS of manual clicks for testing without any software. Selenium can make this simpler by saving us a LOT of effort!

Now, Selenium has a few parts, most significant of which, are the Selenium IDE and the Selenium Webdriver. Selenium IDE is the most widely accepted and user-friendly software of them all. It does not require the prerequisites for any programming language. API commands and arguments are used to program this. However, Webdriver is the perfect one for you if you want to test web automation using programming languages. The languages which Webdriver support are: -
• Java
• C#
• PHP
• Python
• Perl
• Ruby

My reason for writing this blog is because when I had started with Selenium, I really didn’t have a clue where to start from and most of the links weren’t beginner friendly. But don’t worry...I have a few links for you!

https://www.selenium.dev/selenium-ide/docs/en/introduction/getting-started

This link is for the Selenium IDE. If you’re a Mozilla Firefox user like me, you can install the Selenium IDE extension. When you open the browser extension, you can click on the Record button on the top right to have an idea of what the automation feels like. When you click on it, a box pops up asking you to select a base URL. Henceforth, whatever you do in your browser will be recorded for reference. As it is being recorded, the API commands are automatically being stored in the IDE. When you feel like it’s time, just stop the recording. When you click on the play button, whatever you did on the browser for that span will play like a movie. I would suggest studying those commands you see on the screen for a good understanding.

You can find the commands in the link down below.

https://www.selenium.dev/selenium-ide/docs/en/api/commands

HTML has a hierarchical structure implementing Document Object Model or DOM. So, a webpage can be divided into a number of small entities called Elements. For example, the search box in google is an element. The name of your favorite show on Netflix that you click on is an element. I hope you have the idea now. For incorporating an element, you need to inspect it first. For example, if you consider the google search box, right click on it and click on ‘inspect’. This opens a description of the element’s ID, Name, Class name, XPath and CSS Selector location.

Here’s a link to help you with amalgamating HTML elements with Selenium IDE:

https://dev.to/endtest/a-practical-guide-for-finding-elements-with-selenium-4djf

For perspective, here’s a visual representation to make you all understand a little better.

This is a simple project where I automate the browser to open google, search for and open the IMDb page of Tokyo Ghoul, a famous anime, all on its own.

Hope you liked it!

--

--