Webdriver Configuration For Java

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

WEBDRIVER CONFIGURATION FOR JAVA

Tools required for automation using java language.

1. Latest JDK (Java SE Development Kit)


http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
2. Eclipse IDE for Java Developers
http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/mars2
3. Selenium Tool
http://www.seleniumhq.org/download/
4. Testng Jar file
http://www.java2s.com/Code/Jar/t/Downloadtestng685jar.htm
5. Jcommander jar file
http://www.java2s.com/Code/Jar/j/Downloadjcommanderjar.htm
6. Chrome Driver win32
https://chromedriver.storage.googleapis.com/index.html?path=2.29/
7. Gecko Driver for Fire Fox win32
https://github.com/mozilla/geckodriver/releases

Please use the following steps one by one to configure Eclipse with Web Driver.

1. Install JDK
a. Double click on jdk exe file and follow wizard.
b. Go to Environment Variables screen

Add User Variable with the variable value where you install the jdk.
Variable Name: JAVA_HOME
Variable Value: C:\Program Files\Java\jdk1.8.0_131

Go to System Variables section and select Path variable. In path variable past the path of
your installed jdk till bin foler. For Example
“C:\Program Files\Java\jdk1.8.0_131\bin”
c. To check that JDK successfully installed. Open command prompt and type “javac” and
hit enter.
2. Download and double click on Eclipse to open it.
a. Create a new java project using following steps
File > New > Java Project
b. Add Package in src folder
New > Package
c. Add Package name with following convention
com.selenium.configuration.test
3. Add Testng Adson in Eclipse using following steps.
a. Go to Help > Eclipse Marketplace
b. Find TestNG for Eclipse and install it.
c. After installation restart the Eclipse
4. Add Selenium Jar files in the Project using following steps.
a. Download Selenium, TestNG and JCommander jar files.
b. Extract them into a folder.
c. Add them into main project
Left Click on project > Build Path > Configuration Build Path > Java Build Paht > Libraries
> Add External JARs > Select All Jar files > Click Ok

Now you have successfully created java environment.

To test the environment use the following steps.

1. Create a class name “InvokeChrome” in src > com.selenium.configuration.test package


2. Replace the code with the following one

package com.selenium.configuration.test;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;

public class InvokeChrome {

public WebDriver driver;

@Test
public void ChromeProgram()
{
System.setProperty("webdriver.chrome.driver",
"F:\\Automation\\chromedriver.exe");

driver = new ChromeDriver();


driver.manage().window().maximize();
}
}

You might also like