Ankit_Add

Saturday, January 3, 2015

Selenium Web Driver Example

This is a basic program of Selenium.

As you run this program on your machine, it will open Firefox browser and then go to www.google.com and then search Ankit Singhal on google.

This is a first program of Selenim

Anyone, who wants to learn Selenium, this code is very beneficial

Just take this code and run it on your computer and enjoy  

rt org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.io.File;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class Testing1 {

    public void setUp(){
       
        WebDriver driver =  new FirefoxDriver ();     
        driver.get("http://www.google.com");
        WebElement searchBox = driver.findElement(By.xpath(".//input[@name='q']"));
        searchBox.sendKeys("Ankit Singhal");
        driver.findElement(By.name("btnG")).click();
    }
      public static void main(String args[]){
       Testing1 test = new Testing1();
        test.setUp();
    }
   
}

No comments:

Post a Comment