Configuration
Step2: Download the latest “Java”
related “Selenium Client & WebDriver Language Bindings”
Step3: Download the Eclipse
Step4: Create Java project in the
eclipse
Step5: Navigate to Properties,
Select the “Java Build Path”, Click on “Add External JARS…”, browser the
Selenium jars, select both and click on “Open”
Step6: Again navigate to the
Properties, Select the “Java Build Path”, Click on “Add External JARS…”, browse
the libs folder, select all the jars and click on “Open”
Step7: Click “OK”
Sample Script
Once the configuration done,
create a main class with below information and run the script.
Script to open a website in a Firefix browser
import
org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class MainClass {
public static void main(String[] args) {
WebDriver
d1 = new FirefoxDriver();
}
}
Output:
Script to open a website in an Internet Explorer browser
import
org.openqa.selenium.WebDriver;
import
org.openqa.selenium.ie.InternetExplorerDriver;
public class MainClass {
public static void main(String[] args) {
System.setProperty("webdriver.ie.driver", "D:\\Hemanth\\IEDriverServer_x64_2.50.0\\IEDriverServer.exe");
WebDriver ie = new
InternetExplorerDriver();
}
}
Note: To Run the script in
IE, Down load the latest IE driver and mention the IEDriver path. In the above
script the path is D:\\Hemanth\\IEDriverServer_x64_2.50.0\\IEDriverServer.exe
Output:
No comments:
Post a Comment