Minimalist FocusMinimalist Focus
  • Home
  • News
  • Entertainment
  • Fashion
  • Health
  • Tech
  • Tips
  • Travel
  • More
    • Culture
    • Design
    • Life
    • Work
Facebook Twitter Instagram
Minimalist FocusMinimalist Focus
  • Home
  • News
  • Entertainment
  • Fashion
  • Health
  • Tech
  • Tips
  • Travel
  • More
    • Culture
    • Design
    • Life
    • Work
Facebook Twitter Instagram
Minimalist FocusMinimalist Focus
Tech

A Beginner’s Guide to Selenium Automation Testing

By KathySeptember 21, 2023Updated:October 28, 202310 Mins Read
Facebook Twitter Pinterest LinkedIn Reddit Telegram WhatsApp Email
Screenshot 4
Share
Facebook Twitter LinkedIn Pinterest Reddit Telegram WhatsApp Email

Learning Selenium automation can be easier than you think. As a manual tester, one might face many challenges. You can test the application manually when there is a minor improvement or a new feature added to the application to check whether the new addition had not corrupted or caused a failure to work the existing features.

Manual testing is time-consuming and hectic when you need to run the same old test repeatedly and end up forgetting some of the test cases or functionality to test, which can cause major problems when run in production. Explore AlmaBetter’s free tutorials learn topics like html, css, indendation in python, Node.js etc.

That is where the need to automate regular test cases comes in. By automating test cases, you can be more productive and efficient and deliver constructive bug reports effectively to the developers.

Selenium is one of the most popular automation testing frameworks that supports various languages, including Java, JavaScript, and Python, to write test scripts for the application under test.

This article will guide you through a step-by-step process on understanding the know-how of the Selenium test automation framework and how an AI-powered test orchestration and execution platform like LambdaTest can help a software tester by running Selenium automation testing at scale.

What is Selenium?

Selenium is an automation testing suite that allows you to run your test cases over different browsers like Chrome, Firefox, Edge, and more. Selenium scripts can be written in multiple languages like Java, Python, Node Js, Ruby, PHP, and C#. It also supports multiple operating systems like Windows, Linux, and macOS.

Using Selenium, you can write test scripts that mimic the interaction with the elements of a web page over browsers. Since Selenium is focused on testing only web applications, it can not be used to test desktop or mobile applications.

Selenium Components

There are three components of the Selenium suite.

  • Selenium Integrated Development Environment (IDE)
  • Selenium Grid
  • Selenium WebDriver

Selenium IDE

Selenium IDE is an amazing tool for saving time and learning how to write Selenium scripts. IDE has many useful features that allow you to create test cases in various programming languages like Java, Ruby, and PHP. The most popular and commonly used IDEs are Eclipse and IntelliJ.

Selenium Grid

Selenium Grid is a part of Selenium Suites specially designed to run multiple test cases over different browsers.

Selenium WebDriver

WebDriver is a mediator that allows two things to interact with each other, it’s a programming interface that helps to create and execute test cases over different browser platforms. Its basic function is to accept the commands via a test script and send them to the browser.

To use any browser for automation, Selenium provides a built-in or, say, a predefined class called “WebDriver()” that you can just call anywhere in the code to open a browser.

Syntax :

To be more specific, WebDriver is a browser instance in Selenium, and the driver is the variable name. By defining new, we create an instance for the “ChromeDriver()” class    ChromeDriver. As the name suggests, we are trying to run our test script on the Chrome browser.

Setting up your first project with IntelliJ

From the above Selenium IDE, you now know what exactly is an IDE and why we need it for Selenium. So, let’s begin the installation of the IDE.

While performing automation testing, we are currently aware of 2 well-known IDEs, which are Eclipse and IntelliJ.

In this section, we will learn the installation steps for IntelliJ as our IDE.

Prerequisites

  • Java 7 or 8 must be installed in your system.

Step 1: Download the IDEA Community Edition, which is open-source and free, and click on Download.

Step 2: After downloading, click on the installer file .exe and click on the Run button when the security popup appears.

Step 3: Once the security run is completed, the IntelliJ setup welcome screen appears, then click on Next.

Step 4: Select the location of the IDE you want to install it into.

Step 5: Select 64-bit launch as checked and check the .java as your file, as this will allow you to write a script in Java language. Then click on Next.

Step 6: Keep the start menu folder as JetBrains as default and click on Install.

Step 7: That’s it. The installation will take a few minutes, helping you install all the related files.

Creating your first project

After installing the IDE, it’s time for you to start your IDE and start to write your script, but before we get into the details of writing the script, we need to understand and be familiar with the interface and tools that IntelliJ has.

We will start to understand it by creating our first project in IntelliJ.

Step 1: Search IntelliJ from your Windows search bar and click Open.

Step 2: Click on File -> New -> Project.

Step 3: A new window will appear on the screen, which will ask you to enter the details of your project, like the name of your project, which language, and which build system you would like to start with.

In this article, as an example, Maven is used as the build system, and Java is the preferred language. You are free to choose any language as per your need.

Step 4: Click on the Create button.

Great, now you have successfully created your first project.

Folder Structure

There are different folder structures based on your language preference. Let’s walk through the standard structure and learn which folder to write your code. And what is the use of other folders, and what are their needs?

  • .idea

This is the hidden folder of your root project, consisting of all configuration settings of your project and workspace, which includes files that store all the information about your project structure, compiler option, and more. This file is essential and must not be modified or deleted manually.

  • src

This folder consists of the source code of your project divided into subfolders based on the programming language used. Since we are using Java, you will find Java subfolders, including a resources folder, where resources files store all the supportive files required for your code to run, like properties, configuration files, and XML files.

  • target

You might get this target folder, especially if you’re working with Maven or other build tools. This target folder stores the build artifacts, compiled classes, and resources.

  • test

If you are following the TDD approach, you will find this test folder containing unit tests or other tests for your code.

  • lib

Helps store external libraries or dependencies that your project needs.

  • build

Build tools generate this folder, which consists of temporary or compiled files. The content under this folder is generated during the build process and will be deleted without hearing your source code.

  • xml

It contains project details and configuration instructions for Maven. It includes specifications like dependencies, build paths, source and test directories, plugins, and goals. This pom.xml file helps Maven read and then execute the project’s purpose.

These are the essential folders, and we will use them while we are writing our code.

Naming Convention

Now that you know the folder structure and their roles and responsibilities, let’s create some packages and classes.

Creating Package

Make sure the package is created under “Root folder➣ src ➣main ➣ java ➣ Right-click ➣ New ➣ Package “.

Rules for naming the package

  • The package name must always be in lowercase.
  • No special characters or numeric values must be used.

Great, you are now ready with the package creation.

Creation of Java class

Now, let’s add files under the package we created under which we will be writing our code.

Make sure the class is created under “Root folder➣ src ➣main ➣ java ➣ package created (miniprojecttest) ➣ Right-click ➣ New ➣ Java Class“.

Rules for naming the class name

  • Select “Class” from the drop-down and give the class name in the “Capitalization” form. Each following word must be capitalized.
  • No use of special characters or numbers must be used.

Now, you have successfully created a Java class as well.

Add Selenium libraries

Now that you are all set up with basic details and requirements, you must add Selenium to your project. To do so, all you need is the code snippet under your pom.xml

Filename – pom.xml

<dependencies>

<!– https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java –>

<dependency>

<groupId>org.seleniumhq.selenium</groupId>

<artifactId>selenium-java</artifactId>

<version>4.11.0</version>

</dependency>

</dependencies>

To find this Selenium library, you can visit the Maven repository.

Adding WebDrivers to the Script

Selenium suite has support for multiple browsers like Chrome, Firefox, and Edge for each of these browsers. You can implement it using the following Selenium command.

To implement Chrome WebDriver()

Syntax:

WebDriver driver = new ChromeDriver()

To implement Firefox WebDriver()

Syntax:

WebDriver driver = new FirefoxDriver()

To implement Edge WebDriver()

Syntax:

WebDriver driver = new EdgeDriver()

For each browser you try to connect, Selenium imports its library. As you can see in the above Import statement

Running your First Selenium Test Script

In this section, we will learn how to write and run your test script using Selenium.

Test Scenario

Using the created file from the above content, write a code that visits the  LambdaTest Playground using ChromeDriver() and FirefoxDriver().

Code using ChromeDriver()

Visiting the mentioned site using ChromeDriver().

Result using ChromeDriver()

Code using FirefoxDriver()

Result using FirefoxDriver()

Congratulations on running your first Selenium test script successfully,

This was very easy; as you go along with using Selenium automation, you might face challenges, mainly when there is a need for parallel testing where we would need different browser versions and multiple operating systems. Of course, we can not have all sets of browsers in our local system to perform the parallel test simultaneously, But we can surely use a cloud Selenium grid to run Selenium tests at scale.

AI-powered test orchestration and execution platforms like LambdaTest allow you to run Selenium tests over multiple browsers with different combinations of operating systems.

Running your Selenium Script on the cloud

To run your Selenium test script over a cloud-based platform like LambdaTest, all you need to do is follow these steps.

  1. Create an account on LambdaTest.
  2. From the Dashboard, click on the key icon and copy the Username and Access key.
  3. Click on the Automation menu, then click on Web Automation.
  4. Generate capabilities
  • Consider capabilities in LamdbaTest as a configuration file that helps you add a set of instructions and act as a connector or intermediary between your Selenium test script and the LambdaTest platform.
  • You can add as much as the instruction requires, so you need to select the framework you want, and then configure your test.
  1. Under Configure your Test screen, you can see your Username and AccessKey, which are handy to add to your Selenium test script.

Scroll down to add up the Capabilities of your need, these capabilities consist of basic details like your build name, browser, version, timezone, and more. Copy the capabilities and paste them on your Selenium test script

Conclusion

Transitioning from manual testing to Selenium automation can be a scary yet transformative shift in efficiency and productivity. Manual testing, being the traditional process, is more time-consuming and hectic at times. Learning the Selenium automation framework enables testers to execute tests faster across various browsers with Selenium and its components, including WebDrivers(), for browser interaction. It allows testers to get hands-on parallel testing via cloud platforms like LambdaTest.

This blog’s goal is to serve as an entry point to an exciting world of automation, which can help testers simplify complex tasks, Improvise reliability, and validate the capabilities of software testers in today’s dynamic development world.

Share. Facebook Twitter Pinterest LinkedIn Reddit Telegram WhatsApp Email
Previous ArticleInvest in Latest Technology Water Filters for Home Safety and Health
Next Article Top 10 Codeless Automation Testing Tools
Kathy

Meet Kathy, the mindful mind behind the words at minimalistfocus.com. With an innate ability to distill the essence of life down to its purest form, Kathy's writing resonates with those seeking clarity in a cluttered world.

Related Post

How AI is Making Mobile Apps’ Mechanisms Smarter?

May 22, 2025

Optimizing Minimalist Workspaces with Efficient Charging Solutions

May 22, 2025

Elevating Your Home Entertainment Experience in Brisbane

May 22, 2025

Leave A Reply Cancel Reply

Most Popular

Lifestyle

The Art of Sustainable Living in Urban Apartments

By KathyMay 22, 2025

Living sustainably in the city is both smart and important. Cities use a lot of…

The Synergy Between Financial Coaching and a Simplified Life

May 22, 2025

4 Ways to Choose the Right Student Living Apartment for You

May 22, 2025

How to Plan the Perfect Kitchen Design for Renovation

May 22, 2025
Our Picks

Effective Deer Repellent Solutions to Protect Your Garden Naturally

May 22, 2025

The Healing Power of Whale Watching: Nature Therapy on the Coast

May 22, 2025

6 Ways You Can Have Fun in And Around Chicago

May 22, 2025

Top Picks

Truth About How Pros Handle Warm-Weather Bed Bug Surges

May 22, 2025

Heat vs. Chemical Bed Bug Treatments: Which One Actually Works?

May 22, 2025

The Role of a Business Advocate in Boosting Your Company’s Growth

May 22, 2025

Subscribe to Updates

Get the latest creative news from Minimalistfocus about Business, Travel, Tips and More.

  • About Us
  • Archives
  • Contact US
  • Privacy Policy
Minimalistfocus.com © 2025 All Right Reserved

Type above and press Enter to search. Press Esc to cancel.