Single Post

Header

Sunday, November 1, 2015

how to configure selenium webdriver in eclipse

Configure Selenium WebDriver with Eclipse

1.Download Selenium Libraries
http://seleniumhq.org/download/
Language Client Version  Release Date  (Java 2.25.0)   --> zip file
Extract the zip file and put all the jar files in one folder

2. Create a new Java Project in eclipse
File->New->Java Project (Enter any project name)  ->Finish


3. Add Selenium Libraries : In Eclipse
Expand the project (which we created) ->Right Click on (Java System Library) ->Build Path ->
Configure Build Path -> Add External Jars (Click) ->(Browse and Choose all jar files) ->ok

Simple Selenium WebDriver Example :

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class WebBrowser_Open_Get_Close {

    public static void main(String[] args) throws Exception
    {
        WebDriver ff = new FirefoxDriver();
        ff.get("http://www.google.co.in");
        Thread.sleep(3000);
        ff.findElement(By.name("q")).sendKeys("selenium");
        Thread.sleep(2000);
        //    WebElement we= ff.findElement(By.name("q"));
        ff.findElement(By.name("btnG")).click();
        System.out.println(ff.getTitle());
        Thread.sleep(3000);
        ff.close();
      
    }

}

No comments:

Post a Comment