Blog to understand automation concepts in QTP, Selenium Webdriver and Manual Testing concepts

How to Configure Eclipse to work with Selenium

Before starting working with Selenium using Eclipse IDE, we did some configuration that needs to be done for starting and understanding Selenium. This post will explain step wise, how to start working with selenium using Eclipse:


Pre- Conditions: We will require following before beginning the configuration:

1. Java needs to be installed in the machine.

2. Eclipse IDE needs to be installed .

3. Standalone libraries of selenium, at the time of writing this post, I am using selenium-server-standalone-2.33.0.jar

4. Verify in Path variable in User defined variable for machine, is set to the path where standalone libraries is placed as shown below




Configuration Steps: 




Step 1: In eclipse, create a new java project as shown below from File>New Java Project


Create a new Java Project

Step 2: Once a java project is created, right click on project and select option "Build Path>Configure build path

Configure build path of project

Step 3: Click on Add External JAR's and add the selenium standalone jar as shown below.

 Step 4: Now in src for the project, Add a new package, and add a new class as shown below.


Select methods stubs to create as public static void main(String[] args)


                                         

Step 5: Write the code in the class created above and execute. This will open Google in internet explorer . Write selenium in search and click on search.


Code to be placed in void main:


WebDriver ieDriver = new InternetExplorerDriver(); ieDriver.get("http://www.google.com"); WebElement element = ieDriver.findElement(By.name("q")); element.sendKeys("selenium"); element.submit();


No comments:

Post a Comment