Selenium Tutorial

Selenium Tutorial – Learn Selenium from Experts

ITCourCes Selenium tutorial will help you perform your first automation test on Facebook’s login page by learning how elements are located and how automation testing is performed, to generate a test result report using TestNG. This Selenium tutorial will provide you the basic and advanced concepts of Selenium and hence it is designed for both beginners and professionals.

Our Selenium tutorial includes all the topics of Selenium like ‘Introduction to Selenium’, ‘Selenium Types’, ‘What is Selenium WebDriver?’, ‘What is Maven in Selenium?’, and so much more.

Introduction to Selenium

Selenium may be a free (open-source) automated testing suite for web applications that supports cross-browser and cross-operating-system interoperability. It is quite similar to HP’s QuickTest Pro (QTP, now UFT), only that Selenium focuses on automating web-based applications. Testing done using the Selenium tool is typically mentioned as Selenium Testing.

Selenium is useful for testing web applications only. Neither desktop (software) testing nor the testing of mobile applications is feasible with Selenium.

A web application is an application program stored on a remote server that is allowed to get accessed through a web browser over the Internet. Many websites contain web applications. Any website component that performs functions for users qualifies as an internet application. 

Few examples of web applications are:

  • Google Search Engine
  • AliExpress

Coming back, the testing of web applications done through the Selenium tool is referred to as Selenium Testing.

But there surely has to be shortcomings right?

  • We can use Selenium only to check web applications. We cannot test desktop applications or the other software
  • There is no guaranteed support available for Selenium. We need to hold the available customer communities
  • It is impossible to perform testing on images. We need to fuse Selenium with Sikuli for image-based testing
  • There is no native reporting facility. But we will overcome that issue by integrating it with frameworks like TestNG or JUnit

Before going any longer during this what’s Selenium blog, you need to know the story behind how Selenium came into being what it’s today. So, let’s understand the scenario in the below order:

  1. Need for software testing
  2. Challenges with manual testing
  3. How automation testing beats manual testing?
  4. Selenium vs. other testing tools?
  5. Selenium suite of tools 

Need For Software Testing

Software testing is where it all boils right down to. Today’s world of technology is totally dominated by machines, and their behaviour is controlled by the software powering it. Will the machines behave exactly as we would like them to? Every time? Everywhere? The answer to those questions dwells software testing.

At the top of the day, it’s the software application’s success rate which goes to regulate your business growth. The same thing is often said even for web applications because most businesses today are completely reliant on the web.

Take, for example, an e-commerce company. Be it Amazon or eBay or Flipkart, they rely on the customer traffic on their web sites and traffic on their web-based mobile applications for business.

Imagine, if something catastrophic happens just like the prices of a variety of products being capped off at 10$, all due to little bug during a “not so easily readable” part of the code. Then what can be done, and how can we prevent it the next time?

By testing the code before deployment right? So, that is the need for software testing. But, what is Selenium? Is it a software testing tool? Well, Selenium is an automation testing tool!

Before I go any longer, let me make you understand that Software testing is of two types: Manual Testing & Automation Testing. Selenium was founded as an automation testing tool to beat the drawbacks/ limitations of Manual testing. So, in the next section of this selenium blog, let’s understand the challenges with manual testing.

Challenges With Manual Testing

Manual testing means the (web) application is tested to execute the test cases without using any automation tools or manually tested by QA testers or. Tests got to be performed manually in every environment, employing a different data set and therefore the success/failure rate of each transaction should be recorded.

Look at the above image of an inferior chap, who manually confirms the transactions recorded. The challenges he’s facing cause fatigue, boredom, delay in work, mistakes and errors due to manual effort. This led to the invention of Selenium (automation testing tool). 

Automation Testing Beats Manual Testing

Automation testing beats manual testing every time. Why? Because it’s faster, needs less investment in human resources, it’s not susceptible to errors, frequent execution of tests is feasible, supports lights out the execution, supports regression testing and also functional testing.

Let’s take a similar example to the one mentioned earlier. Suppose there’s a login page and that we got to verify if all the login attempts are successful, then it’ll be very easy to write down a bit of code which can validate if all the transaction/ login attempts are a hit or not (automated test suit execution).

Moreover, these tests can be configured in such a way that they are tested in different environments and web browsers. What else can be done? You can automate the generation of the result file, by scheduling it for a particular time during the day. Then you can also automate the generation of reports based on those results and whatnot.

The key point is that automation testing makes a tester’s job an entire lot simpler. Check out the image below which shows a more relaxed environment during which an equivalent tester is functioning.

 .Now, let me talk about Selenium in particular.

Now allow us to see where Selenium stands within the market.

Selenium vs QTP vs RFT:

I have compared its performance with two other popular tools: QTP and RFT in the table below.












Open-source software

Customer Support

Dedicated HP support

Dedicated IBM support

Open-source Community

Hardware consumption during script execution




Coding experience

Not required


Ample amount of coding skills and experience needed

Environment support

Only for Windows

Only for Windows

Windows, Linux, Solaris OS X (If browser or JavaScript support exists)

Language Support

VB Script

Java and C#

Java, C#, Ruby, Python, Perl, PHP and JavaScript

It is pretty clear from the above table why Selenium is the most preferred tool. But there are many flavors in Selenium and you should know which is the appropriate right Selenium tool for your needs.

Selenium Types

Selenium isn’t just one tool but a set of software, each catering to different testing needs of a corporation . It has four components:

  • Selenium Integrated Development Environment (IDE)
  • Selenium Remote Control (RC)
  • Selenium Grid
  • Selenium WebDriver

Now that you know about its types, let’s talk about each of them briefly.

Selenium IDE

Selenium IDE (Integrated Development Environment) is a tool that helps you develop your Selenium test cases. It’s an easy-to-use Chrome and Firefox extension and is generally the most reliable method to develop test cases. It records users’ actions in the browser for you, using the existing Selenium commands, with parameters defined by the context of the web element. This is not only a time-saver but also a superb way of learning Selenium script syntax. Previously known as Selenium Recorder, Selenium IDE was initially created by Shinya Kasatani, of Japan and contributed to the Selenium project in 2006.

It was introduced as a Firefox plugin for faster creation of test cases. As it was a Firefox extension, it could automate the browser through a record-and-play feature providing autocompletion support and the ability to move commands around quickly.

Scripts are recorded in a special test scripting language called Selenese for Selenium. Selenese comes up with commands for carrying out actions in a web browser and restoring data from the resulting pages.

The advantage of Selenium IDE is that the tests recorded via the plugin can be exported in different programming languages like Java, Ruby, Python, etc.

Selenium RC (Remote Control)

Let me first tell you that Selenium Core was the primary version. But with that version, testers had to install both Selenium (a JavaScript program) and the webserver containing the web application being tested on their local systems so that they would belong to the same domain.

Then, another ThoughtWorks’ engineer, Paul Hammant resolute to make a server which will act as an HTTP proxy to trick the browser into believing that Selenium Core and therefore the web application being tested belong to an equivalent domain, thus making RC a two-component tool.

  • Selenium RC Server
  • Selenium RC Client (Library containing the programing language code)

RC can support the following programming languages:

  • Java
  • C#
  • PHP
  • Python
  • Perl
  • Ruby

Selenium Grid

Selenium Grid may be a testing tool that allows you to run your tests on various machines against different browsers. It is part of the Selenium retinue that specializes in running various tests over different browsers, operating systems, and machines. You can connect to it with Selenium Remote Control by stating the browser version, browser, and operating system as per your choice. You will be able to specify these values through Selenium Remote Control capabilities. With Selenium Grid, one server makes a move as a hub. Tests communicate to the hub to get access to browser instances. The hub has a list of servers that provide access to browser instances (WebDriver nodes) and lets tests use these instances.

Selenium Grid allows parallel testing and also allows managing different browser versions and browser configurations centrally (instead of in each individual test).

There are multiple online platforms that provide a web Selenium Grid that you simply can access to run your Selenium automation scripts. For example, you can use LambdaTest.

Selenium Grid has more than 2,000 browser environments over which you can run your tests and truly automate cross-browser testing.

Selenium WebDriver

Founded by Simon Stewart in 2006, ThoughtWorks consultant in Australia. Selenium WebDriver was the first cross-platform testing framework that would control the browser at the OS level. Selenium WebDriver is a successor to Selenium RC. Selenium WebDriver receives instruct (sent in Selenium or via a Client API) and addresses them to a browser.

This is applied through a browser-specific driver, which sends instructions to a browser and retrieves the results. Each driver launches and accesses a browser application. Different WebDrivers are:

  • Firefox Driver (Gecko Driver)
  • Chrome Driver
  • Internet Explorer Driver
  • MicroEdge
  • Opera Driver
  • Safari Driver
  • HTML Unit Driver

Benefits of Selenium WebDriver

  • Selenium WebDriver supports seven programming languages: Java, C#, PHP, Ruby, Perl, Python, and .Net.
  • It supports cross-browser interoperability that helps you perform testing on various browsers like Firefox, Chrome, IE, Safari, etc.
  • Tests can be performed on different operating systems: Windows, Mac, Linux, Android, and iOS.
  • Selenium WebDriver overcomes limitations of Selenium v1 like file upload, download, pop-ups, and dialog barrier

Cons of Selenium WebDriver

  • Detailed test reports cannot be generated.
  • Testing images is not possible.

No matter what, these shortcomings can be overcome by integrations with other frameworks. That is, for testing images Sikuli can be used, and for generating detailed test reports, TestNG can be used.

Now, you know what Selenium is and have a fair idea about the various tools of the Selenium suite.

Next, I will tell you everything you need to know to get started with testing web apps using Selenium WebDriver. The below image depicts how WebDriver works:

Selenium WebDriver

Before I get started with Selenium WebDriver, let me show you the topics I will be covering in this blog which will help you write your first Selenium code for automation testing. In this blog, I even have written Selenium code to check automated login to Facebook. The topics are:

  • Drawbacks of Selenium RC and therefore the birth of WebDriver
  • What is Selenium WebDriver?
  • What are browser elements?
  • Locating browser elements on a web page
  • Operations on browser elements

Drawbacks Of Selenium RC and therefore the Birth Of WebDriver

Let’s first discuss the limitations of Selenium RC because that was the reason for the eventual development of WebDriver. You might be surprised when I say that Selenium RC became an instant hit when it was launched. That was because it overcame the same-origin policy issue which was a major problem while testing web apps with Selenium Core. But do you know what the same-origin policy issue was?

The same-origin policy is rules which enforce web application, security models. According to the same-origin policy, the web browser will allow JavaScript codes to access elements on the web page, if and only if both the JavaScript and web page being tested are hosted from the same domain. Selenium Core is a JavaScript-based testing tool, was handicapped for the same reason that it could not test every web page.

But when Selenium RC came into the image, it rid testers of the same-origin policy issue. But, how did RC do that? RC did that by working on other elements called Selenium RC server. So, RC may be a tool which may be a combination of two components: Selenium RC server and Selenium RC client.

Selenium RC server is an HTTP proxy server, designed to “trick” the browser into believing that Selenium Core and therefore the web application being tested are from an equivalent domain. Hence, there’s no stopping the JavaScript code from accessing and testing any internet site.

Even though Selenium RC was a serious hit, it had its own share of problems. The major one being the time taken for executing tests. Since the Selenium RC server is that the middle man within the communication between the browser and your Selenium commands, test executions are very time-consuming. Besides the time factor, RC’s architecture is additionally slightly complicated.

This architecture involves first injecting Selenium Core into the online browser. Then Selenium Core will accept the commands from the RC server and transform it into a JavaScript command. This JavaScript code is liable for accessing and testing the online elements. If you look at the image below, you will get an idea of how RC works.

To overcome these problems, the Selenium WebDriver was developed. WebDriver is quicker because it interacts directly with the browser and there’s no involvement of an external proxy server. The architecture is also simpler as the browser is controlled from the OS level. The below image will help you understand how WebDriver works.

Another benefit with WebDriver is that it supports testing on the HTMLUnit driver which is a headless driver. When we say a headless driver, it refers to the fact that the browser has no GUI. RC on the other hand does not support HTML Unit drivers. These are some of the reasons why WebDriver scores over RC.

What Is a Selenium WebDriver?

In this part of Selenium tutorial blog, I will dig deep into Selenium WebDriver. There is a good chance that you will be aware of the details I have covered in the below paragraph, but I will be revising it anyway.

Selenium WebDriver may be a web-based automation testing framework which may test sites initiated on various web browsers and various operating systems. In fact, you furthermore may have the liberty to write down test scripts in several programming languages like Java, Perl, Python, Ruby, C#, PHP and JavaScript. Do note that Mozilla Firefox is Selenium WebDriver’s default browser.

WebDriver was introduced as part of Selenium v2.0. Selenium v1 subsist only IDE, RC and Grid. But the main breakthrough within the Selenium project was when WebDriver was developed and introduced as a replacement in Selenium v2. However, with the release of Selenium v3, RC has been deprecated and moved to a legacy package. You can download and work with RC but don’t predict any support for it.

In a nutshell, the benefits WebDriver has over RC are:

  • Support for more programming languages, OS and web browsers
  • Overcoming the limitations of Selenium 1 like file upload, download, pop-ups & dialogue barrier
  • Simpler commands in comparison to RC, and a far better API
  • hold up for Batch testing, Cross-browser testing & Data-driven testing

But the disadvantage in comparison to RC is that the test reports can’t be generated. RC generates detailed reports.

The below image depicts how WebDriver works:

You must have heard the term “browser elements” variety of times. The next a part of this Selenium tutorial is going to be about what are these elements and the way testing happens on these web elements.

What Are Browser Elements?

Elements are the different components that are present on web pages. The most common elements we notice while browsing is:

  • Text boxes
  • CTA Buttons
  • Images
  • Hyperlinks
  • Radio buttons/ Checkboxes
  • Text area/ Error messages
  • Drop down box/ List box/ Combo box
  • Web Table/ HTML Table
  • Frame

Testing these elements essentially means we have to check whether they are working fine and responding the way we want it to. For example, if we are testing text boxes, what would you test it for?

  1. Whether we are able to send text or numbers to the text box
  2. Can we recover text that has been moved to the text box, etc?

If we are testing an image, we might want to:

  1. Download the image
  2. Upload the image
  3. Click on the image link
  4. Retrieve the image title, etc.

Similarly, operations can be performed on each of the elements mentioned earlier. But only after the elements are located on the web page, we can perform operations and start testing them right? So, subsequent topic, i will be able to be covered during this Selenium tutorial blog is element locator techniques.

Locating Browser Elements Present On The Web Page

Every element on an internet page will have attributes (properties). Elements can have quite one attribute and most of those attributes are going to be unique for various elements. For example, consider a page having two elements: a picture and a text box. Both these components have a ‘Name’ attribute and an ‘ID’ attribute. These attribute values got to be unique for every element. In other words, two elements cannot have an equivalent attribute value. Elements can have an equivalent value for ‘Class Name’.

In the example considered, the image and text box can neither have an equivalent ‘ID’ value nor an equivalent ‘Name’ value. However, there are some attributes that can be common for a group of elements on the page. I will tell you which of them are those attributes later, but before that permit me to list down the 8 attributes using which we will locate elements. Those features are ID, Name, Class Name, Tag Name, Link Text, Partial Link Text, CSS and XPath.

Since the weather are located using these attributes, we ask them as ‘Locators’. The locators are:


Syntax: driver.findElement(“xxx”));


Syntax: driver.findElement(“xxx”));

  • By.className

Syntax: driver.findElement(By.className(“xxx”));

  • By.tagName

Syntax: driver.findElement(By.tagName(“xxx”));

  • By.linkText

Syntax: driver.findElement(By.linkText(“xxx”));

  • By.partialLinkText

Syntax: driver.findElement(By.partialLinkText(“xxx”));

  • By.css

Syntax: driver.findElement(By.css(“xxx”));

  • By.xpath

Syntax: driver.findElement(By.xpath(“xxx”));

By watching the syntax above, you would possibly have realized locators are called inside methods. So, before going any further, you need to learn all the other methods, browser commands and functions that can be used to perform operations on the elements.

Operations On Browser Elements

From this section of the blog onwards, you will be having a lot of fun because there will be less theory and more codes. So be prepared, and keep your Eclipse IDE open with the specified Selenium packages installed.

To start testing an internet page, we’d like to first open a browser, then navigate to the online page by providing the URL right? Check out the below piece of code, where I have replicated the same. Firefox browser will first be initiated and then it will navigate to Facebook’s login page.

package seleniumWebDriver;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

 public class WebDriverClass


public static void main(String[] args)


System.setProperty(“webdriver.gecko.driver”, “files/geckodriver.exe”);

WebDriver driver = new FirefoxDriver();






import org.openqa.selenium.WebDriver; may be a library package which contains the specified class to initiate the browser loaded with a selected driver.

import org.openqa.selenium.firefox.FirefoxDriver; may be a library package which contains the FirefoxDriver class needed to start out FirefoxDriver because the browser initiated by the WebDriver class.

System.setProperty(“webdriver.gecko.driver”, “files/geckodriver.exe”); – This command notifies the run-time engine that the Gecko driver is present within the specified path. After Firefox 35, we’d like to download the Gecko driver for working with WebDriver. In case you want to test on chrome, then you have to download ChromeDriver, which is a .exe file and specify it’s path in this line of code. We have to do it similarly in case of other browsers also.

WebDriver driver = new FirefoxDriver(); – This command is employed to initiate a replacement Firefox driver object.

driver.get(“”); – This method is used to open the specified URL.

driver.getTitle(); – This command gets the title of the tab that is currently open in the browser.

driver.quit(); – This command closes the browser driver.

But, what if you want to navigate to a different URL and then do testing? In that case you can use the command as shown in the below code snippet. If you then want to come back to the previous page, then you can do that by using navigate.back() command. Similarly for refreshing the present page, you’ll use navigate.refresh() command.




If you want to maximize the size of the browser window, then you can do that by using the code in the snippet below.



In case you want to set a custom size for the browser window, then you can set your own dimensions as shown in the below code snippet.

Dimension d = new Dimension(420,600);


Now that you know most of the basics, let’s go to the next topic in this Selenium tutorial blog. Let’s try to find an element on the web page and then perform any operation that is possible.

I’m pretty sure, you all have Facebook accounts. So, let me show you how to log into Facebook by passing the credentials from the code itself.

There are two text fields in the Facebook login page, one for Email/Phone and another for Password. We have to locate these two elements, pass the credentials to those elements and then find the third element: Login button which needs to be clicked on.

Look at the screenshot below. It is the screenshot of Facebook’s login page.

If you Inspect (Ctrl + Shift + i) this page, then you will get the same window in your browser. Then, under Elements, a list of all the weather present on the page and their attributes are going to be displayed. There are three portions highlighted in the above screenshot. The first highlighted element is an email text field, the second is the password text field and the third is the Login button.

If you’ll recall, I discussed earlier that these elements are often located using element locator techniques. Let’s use it to locate these elements and send the sector values.

This is the syntax for detecting the element: driver.findElement(“xxx”));

For sending it values, we can use the method sendKeys(“credentials“);

For clicking on a button, we have to use the method click();

So, let’s get started with finding the element and performing an operation on it. The code for it is in the below snippet.




driver.findElement(“email”)).sendKeys(“[email protected]”);



In line #1, we are identifying the Email element by its unique ‘Name’ attribute and sending it the EmailID. 

In line #2, we are identifying the Password element by its unique ‘Name’ attribute and sending it the password.

In line #3, we are locating the Login button element by its unique ID and clicking on that button.

Adding just these lines of code might not be enough. That is because of the dynamics of the page, it might not respond immediately and by the time the page loads, WebDriver will get terminated and throw a timeout exception error. This issue might not happen on Facebook’s page because it is fast but will most likely happen in any other E-Commerce site and other dynamic web sites.

To overcome this problem, we need to use an advanced technique. We need to request our WebDriver to wait after the page is accessed and after it loads completely, we need to locate the elements and then perform actions.

In case you want your WebDriver to wait until all the elements load in a web page and then close the browser, then we can achieve that by using a driver.wait() method or Threads.sleep() method. However, if you are writing more advanced code, then you should use Implicit waits or Explicit waits. In the next blog of this Selenium tutorial series, I will clarify the concept of wait conditions. But for our case, the below commands are enough.





// or use this:-


But, while working with wait conditions, remember to import this library:

import java.util.concurrent.TimeUnit;

We do it because the class to wait and its related methods will be present in this library.

The entire code I explained, is present in the below code snippet.

package seleniumWebDriver;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

import java.util.concurrent.TimeUnit;


public class WebDriverClass


public static void main(String[] args)


System.setProperty(“webdriver.gecko.driver”, “files/geckodriver.exe”);

WebDriver driver = new FirefoxDriver();








// or use

// Thread.sleep(5000);

 driver.findElement(“email”)).sendKeys(“[email protected]”);






When you replace the credentials with your actual email and password and execute this code, then Facebook will open in a new window, enter your credentials and login to your account.

Voila! You have successfully logged in, which means your complete code executed completely.

I have used the ID and Name attributes for locating elements. You can use any locator for finding the elements. XPath is the most utility and foremost of locator techniques. But, as long as you can find even one of the attributes and use them for locating elements, you should be good. You can see the below video delivered by an industry expert, where she has shown all the above-mentioned features of Selenium WebDriver with hands-on.

What is Maven in Selenium?

Maven is a build automation tool used primarily for Java projects by downloading its dependencies.

Basically, Maven is a software that helps you download dependencies for a software program. When you create a Selenium project, you need to specify all Selenium components which are required to be included inside a POM file for the Selenium project to be ready. Once the dependencies are added in the POM file, you can simply save the project and all these dependencies will automatically be downloaded.

Setting up Selenium with Maven and TestNG on Eclipse:

Before diving into this section of the Selenium tutorial, let’s see how Eclipse projects run. For making Eclipse Java projects run, you need a library that gives the ability to produce an HTML report of execution and display the test case that has failed, which is done by TestNG library. When bugs can be accurately located like this, they can be fixed immediately to the relief of developers.

TestNG is a testing framework. It structures, groups, and launches tests. It also generates testing reports. To get a function executed, we need to include @Test annotation before the definition of that function.

When you run this file as a TestNG suite, the execution will start and you will get the detailed test reports. You will get the test output in your console tab and the result of the test suite in the next tab.

You decided to use TestNG for several reasons:

  1. TestNG annotations are easy-to-create test cases.
  2. Test cases can be grouped and prioritized more easily.
  3. TestNG supports parameterization.
  4. It also supports data-driven testing using data providers.
  5. It generates HTML reports.
  6. Parallel test execution is possible.
  7. TestNG readily supports integration with other tools and plugins like Eclipse IDE and build tools like ANT, Maven, etc.

Now, this tutorial will move on with the hands-on part. This section is divided into three parts:

  • Java JDK Installation
  • Eclipse Installation
  • Performing the Selenium Test Case

Installing Java JDK:

Step 1: Download Java JDK from the link provided below then click on the Oracle JDK Download button

Click on the radio button, Accept License Agreement, and download the .exe file associated with your OS type

Step 2: Open the downloaded execution file, and click on on Next

Step 3: Select Developers Tools and click on on Next, and you’ll be directed to the below screen. it’ll take a couple of moments to line up JDK in your system

Step 4: Click on on the brink of complete the found out 

Before moving ahead, you would like to feature the environment variables to the trail as follows.

Step 5: attend local C drive > Program Files > Java > jdk-12.0.1 > bin

Step 6: Copy the trail as shown above

Step 7: attend instrument panel > System and Security > System > Advanced system settings > System Properties

Step 8: Click on Environment Variables as shown above and therefore the below window pops up during which you’ll perform the subsequent steps:

  1. Click on Path within the System variables section, under Environment Variables
  2. Click on Edit

Step 9:

  1. Click on Browse and find your file path as local C drive > Program Files > Java > jdk-12.0.1

Keep clicking ‘OK’

  1. Now, you’ve got Java JDK installed in your system

 Installing Eclipse:

Step 1: attend the Eclipse download page (the recent one is Eclipse Installer 2019-06 R), with this link:

Step 2: Click on Download 64 bit. you’d land on a page as shown below:

Step 3: Once the download is finished, launch the installer

Step 4: Click on Eclipse IDE for Enterprise Java Developers

Step 5: Once done, click on INSTALL

Step 6: Then, click on Launch

Now that you simply have successfully found out Java and Eclipse in your environment, let’s perform a Selenium test suit using Maven.

Performing Selenium test suit 

Step 1: Start a replacement Maven Project

Step 2: Check the Create an easy project checkbox and click on on Next

Step 3: Enter Group Id and Artifact Id and click on on Finish

Group Id: Group Id is that the Id of the project’s group. Generally, it’s unique among a corporation .


Artifact Id: Artifact Id is that the Id of the project. It specifies the name of the project.

Step 4: Now, your project would seem within the Project Explorer section as shown below:

Before moving on to the scripting part, you would like to configure the Maven Dependencies to perform Selenium test suit in Eclipse. you’ll be adding the Maven Dependencies to the pom.xml file under the target folder.

Step 5: Now, plow ahead and add the below dependencies to the pom.xml file

Note: Copy the code from below and paste it after the junit dependency which can be already present in your .xml file
























Step 6:

  1. Right-click on the file name
  2. Click on Properties

Step 7:

  1. Select Java Build Path
  2. Click on Libraries
  3. Click on Add Library

 Step 8:

  1. Click on TestNG
  2. Press Next then Finish

Step 9: Click on the Apply and shut button

Step 10: attend, right-click on the page, and click on on Inspect

Step 11: Follow the method shown below and replica the xpath of email:

  1. you’ll use this arrow to pick a component within the page to examine it
  2. Select the e-mail web-element, which can point to the section of this web-element’s html code
  3. Click on Chropath, this helps you in getting Xpaths and CSS selectors for web elements of an internet page, uniquely
  4. Copy the RelXpath. XPath is defined as XML path. it’s a syntax or language for locating any element on internet page using XML path expression

Step 12:

  1. Paste the xpath within the xpath i.e., key)
  2. Enter the worth (email ID)

Step 13: Do an equivalent for password xpath

Step 14: Do an equivalent for login xpath also 

Step 15: Your code would appear as if this:


public class App

 WebDriver driver;

 public void test()



 driver = new ChromeDriver();

 //The website name you would like to go to 


 driver.findElement(By.xpath(“//input[@id=’email’]”)).sendKeys(“[email protected]”);





 Note: Here, you want to provide a legitimate email ID and password. during this example, dummy ID and password would be used.

Step 16:

  1. Right-click on the screen and scroll right down to Run As
  2. Click on 1 TestNG Test

Step 17:

  1. Once done, the Chrome browser window will crop up 
  2. it’ll look for
  3. Then, it’ll automatically type the e-mail 
  4. it’ll automatically type the password also 
  5. it’ll then click on Log in and navigate you to your FB homepage

Step 18: You’ll be navigated to your FB account

Step 19: attend Eclipse IDE again and see the console. you’d see the Test report with the results

That’s it! you’ve successfully performed a Selenium test suit .

Creating Automated Tests

There are three steps to execute automated tests:

  • Find an element on the web browser
  • Perform action on that element
  • Test and create a test report with the results

Finding an Element on the Web Browser

An element on a web browser can be found using:

  • ID
  • Name
  • Class Name
  • Tag Name

Performing an Action on That Element

The next step is performing an action. For that you can try the following options:

  • Click(): Used to click on a web element
  • sendKey(): Used to take values into text boxes
  • Clear(): Used to clear textboxes of its current value
  • Submit(): WebDriver will automatically activate the present function of the web application where that element belongs to

Testing and Reporting

Report generation is extremely vital once you do the Automation Testing, likewise as for Manual Testing. By looking at the result, you can easily identify how many test cases are passed, failed, and skipped. By viewing the report, you’ll come back to understand what the status of the project is.

Selenium Internet Driver is employed for automating the web-application, however, it will not generate any reports. TestNG will generate the default report.

Selenium Career Opportunities

As numerous companies have started using web applications, the need for Selenium is shooting up. It has grown tremendously and has become one of the most integral parts of various businesses. When it comes to web testing tools, Selenium has surely become one of the best in the industry to help you with automation testing services.

There are various career opportunities for a tester. Below mentioned are some of the popular job roles you can consider to work as a Selenium WebDriver professional:

  • Automation Test Lead
  • Senior Test Engineer
  • Quality Engineer
  • Selenium Automation Analyst
  • QA Engineer

The most interesting part here is that the industry has experienced a humongous surge in creating job opportunities with very exciting packages. So, you must take the assistance of experts and get yourself qualified enough to make the best of these opportunities.

WhatsApp chat

Schedule a demo

We will schedule the demo with an expert trainer as per your time convenience.

Have a query?

we'd love to assist and help you on anything related to IT courses.