Set up Java for automation using selenium web driver

In this tutorial, we are going to set up Java for automation using selenium web driver. The basic requirement to start automation using selenium web driver with java is JDK. Let’s see step by step process to install JDK on your machine.

How to Set up Java for automation using selenium web driver

Configure Java development tools(JDK)

  • Download the latest version of JDK and install.
  • Just follow the instruction and Install JDK and to confirm just check c — >program files –> java

To download JDK Follow the below steps:

Visit the official website http://www.oracle.com/technetwork/java/javase/downloads/index.html

Accept license or terms and conditions.

Choose a file according to your operating system.

 

NOTE: Simply install like other software you just need to double click on the downloaded .exe file and follow the instructions carefully and confirm the installation.

 

Set path of javac file to access globally

How to set path in java please play the video and follow some easy steps.

How to setup IDE (Eclipse or Net Beans)

Downloads Eclipse from official website of Eclipse org https://www.eclipse.org/downloads/

Note: If you are using a window machine you need to check you are using 32bit or 64bit. Download the file according to your operating system.

Download the latest version of eclipse.

 

After download extract the Zip file and open the eclipse folder and Run the application by click on the eclipse icon.

 

Congrats,  Now your eclipse is configured successfully.

Open eclipse When you run this first time it will ask you to choose a work directory or workspace you need to select a folder on your HDD or It will store your project in the default directory.

 

Create a new project or your first project with a selenium web driver.

File-> new->Java project

Automation with java

If you are not getting Java project in the list then you need to click on others and search for a java project.

Demo Automation script with java using eclipse

package com.SeleniumEasyTestCases;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class SeleniumWithCodebun {
 
 static WebDriver driver;
 
 public static void main(String args[]){
  
  System.setProperty("webdriver.chrome.driver","D:\\Automation\\selenium\\lib_files\\chrome\\chromedriver.exe");
  driver=new ChromeDriver();
  driver.manage().window().maximize();
  driver.get("http://www.seleniumeasy.com/test/");
  driver.close();
 }

}

Note: This script is only for the demo we will see code explanation and everything in detail in the upcoming tutorial.

Step by step automation tutorial with java