Top Banner
Dasun Eranthika How to Configure Selenium WebDriver (Java) 1
19
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: How to Configure Selenium WebDriver (java)

Dasun Eranthika

How to Configure Selenium WebDriver (Java)

1

Page 2: How to Configure Selenium WebDriver (java)

Content

Create a Project Configure Firefox Configure Chrome Configure Internet Explorer

You must pre-download eclipse

April 18, 2023

2

How to Configure Selenium WebDriver (Java) | Dasun Eranthika

Page 3: How to Configure Selenium WebDriver (java)

Create a Project

Open eclipse Right click on Package Explorer > New > Java Project

April 18, 2023

3

How to Configure Selenium WebDriver (Java) | Dasun Eranthika

Page 4: How to Configure Selenium WebDriver (java)

Create a Project

Give a Project name and click Next

April 18, 2023

4

How to Configure Selenium WebDriver (Java) | Dasun Eranthika

Page 5: How to Configure Selenium WebDriver (java)

Create a Project

Go to Selenium downloads page and download Java Language bindings

Extract it in your local drive

April 18, 2023

5

How to Configure Selenium WebDriver (Java) | Dasun Eranthika

Page 6: How to Configure Selenium WebDriver (java)

Create a Project

Right Click in your project > Properties

April 18, 2023

6

How to Configure Selenium WebDriver (Java) | Dasun Eranthika

Page 7: How to Configure Selenium WebDriver (java)

Create a Project

Java Build Path > Libraries

April 18, 2023

7

How to Configure Selenium WebDriver (Java) | Dasun Eranthika

Page 8: How to Configure Selenium WebDriver (java)

Create a Project

Click “Add Library..” button and add JAR files (include files in “libs” folder)

April 18, 2023

8

How to Configure Selenium WebDriver (Java) | Dasun Eranthika

Page 9: How to Configure Selenium WebDriver (java)

Create a Project

After import JAR files, you can see “Referenced Libraries” folder

April 18, 2023

9

How to Configure Selenium WebDriver (Java) | Dasun Eranthika

Page 10: How to Configure Selenium WebDriver (java)

Configure Firefox

Create new class file and enter following code

April 18, 2023

10

How to Configure Selenium WebDriver (Java) | Dasun Eranthika

import org.openqa.selenium.firefox.FirefoxDriver;

public class Uers {

public static void main(String[] args) {FirefoxDriver fd = new FirefoxDriver();fd.get("http:/google.lk");}

} Site URL

Page 11: How to Configure Selenium WebDriver (java)

Configure Firefox

Google opens through Firefox

April 18, 2023

11

How to Configure Selenium WebDriver (Java) | Dasun Eranthika

Page 12: How to Configure Selenium WebDriver (java)

Configure Chrome

Download chrome driver from selenium download page third party section and extract it

April 18, 2023

12

How to Configure Selenium WebDriver (Java) | Dasun Eranthika

Page 13: How to Configure Selenium WebDriver (java)

Configure Chrome

Enter following code

April 18, 2023

13

How to Configure Selenium WebDriver (Java) | Dasun Eranthika

import org.openqa.selenium.chrome.ChromeDriver;

public class Uers {

public static void main(String[] args) {System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\chromedriver.exe");ChromeDriver cd= new ChromeDriver();cd.get("http://google.lk");

}

}

Site URLLocation of chromedriver

Page 14: How to Configure Selenium WebDriver (java)

Configure Chrome

Google opens through Chrome

April 18, 2023

14

How to Configure Selenium WebDriver (Java) | Dasun Eranthika

Page 15: How to Configure Selenium WebDriver (java)

Configure Internet Explorer

Download Internet Explorer (IE) driver from selenium download page and extract it.

April 18, 2023

15

How to Configure Selenium WebDriver (Java) | Dasun Eranthika

Page 16: How to Configure Selenium WebDriver (java)

Configure Internet Explorer

Enter following code

April 18, 2023

16

How to Configure Selenium WebDriver (Java) | Dasun Eranthika

import org.openqa.selenium.ie.InternetExplorerDriver;

public class Uers {

public static void main(String[] args) {System.setProperty("webdriver.ie.driver", "C:\\Selenium\\IEDriverServer.exe");InternetExplorerDriver id= new InternetExplorerDriver();id.get("http://google.lk");

}

}

Site URL Location of IEdriver

Page 17: How to Configure Selenium WebDriver (java)

Configure Internet Explorer

Google opens through IE

April 18, 2023

17

How to Configure Selenium WebDriver (Java) | Dasun Eranthika

Page 18: How to Configure Selenium WebDriver (java)

Complete code

April 18, 2023

18

How to Configure Selenium WebDriver (Java) | Dasun Eranthika

ConfigBrowsers.txt