How to write first test case in Selenium Webdriver?

As we all know, Software testing is a technique to test and compare the actual outcome with the expected outcome to validate the application functionality/Performance. To validate the functionality of apps, a tester can achieve this by Manual Testing or Automation Testing. Manual Testing as named, Tester has to check the whole testing like the functionality of application manually. He has to create reports, traceability matrix, test plans, etc. manually and the worst thing is he has to perform similar/same actions multiple times. On the other hand, Automation testing changed the way to do testing. You just need to write a test script and call multiple times or reuse the script to test another application.  

The way the IT Industry is growing these days. Automation testing has brought a huge shift in software testing. There are so many automation testing tools available in the IT market. Selenium is one of the most infamous and highly-demanded tool. It is open-source that is designed to test the application. It comes in 2 different types: 

  1. Selenium IDE
  2. Selenium Webdriver(support different programming libraries)
  3. Selenium Grid 

As a beginner, one common question comes to our mind “Where and How to start learning? Or How to write the first test script in Selenium Webdriver?”

Before start learning or writing a simple test script, we need to check prerequisites or what skills we need which are as follows:

  1.  Java Programming 
  2. Basics of HTML5
  3. Basics of CSS & Javascript
  4. Hands-on experience on Eclipse IDE
  5. Import Selenium Jar files into Eclipse project
  6. And your curiosity

If you don’t have knowledge of Java programming. Just enroll in our Java for Automation Testing course. Besides Java programming, you need basic knowledge of HTML5, CSS & Javascript to understand webpages’ components. To learn about web page components, you can enroll in our following courses:  

  1. HTML5
  2. CSS
  3. Javascript

Okay, so we have seen what skills we need to write a test script. Now it is time to write a simple test script but what page can we test or where to start testing the application?  The answer is the homepage where we can start testing because every domain like E-learning or E-commerce application has a homepage which is the gateway to enter. 

Let’s write the steps to check the home page is opening. 

  1. Create a Java project.
  2. Import Selenium Jar files into the project.
  3. Create a simple Java class OpenWithChrome with package details.
  4. Write statement into the main method to create an instance of Selenium WebDriver. 
  5. Download chromedriver and configure the browser 
  6. Navigate to URL.
  7. Check the status.

Let’s Automate Selenium Login with Java. Here are some important statements of the code.

  • Create an instance of Selenium WebDriver
ChromeDriver driver=new ChromeDriver();

In order to launch the website, we need to set the webdriver instance with a chrome browser. 

  •  Configure browser

Based on the needs, we need to set system properties to the path of the driver for the required browser.


System.setProperty("","file path for driver path");

By default, the size of the chrome browser is minimized.  To maximize, we need 

To maximize the browser window.


  • Navigate to url.

To open the required site into the browser. 

Syntax :

  • To check if the site’s homepage is open, we need to check that code should not throw a runtime error. If it is not throwing any error it means the site’s home page opened successfully. 

Below is the complete code of home page automation.

package seleniumpractice;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

public class OpenWithChrome {

public static void main(String[] args) {

System.setProperty("", "file path for driver path");

ChromeDriver  driver=new ChromeDriver();        



System.out.println("website opened");




To get more details or wants to learn & become an automation tester, Please visit the below URL:

ITlearn360 has launched a very affordable plan to become a QA Tester/ Automation Tester.  You just need to pay $1 a day and learn various technologies like:

  • Learn Java programming
  • STLC
  • Agile Methodology
  • JIRA for Project Management
  • DevOps
  • Git
  • Jenkins for Continuous Delivery
  • Testing Approaches
  • Hybrid Test Framework  


To get more details, please visit

Happy Learning 😀