1.下载chrome驱动chromedriver.exe,登陆百度
package com.siteTest;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
public class siteTest {
@Test
public void showBaidu(){
System.setProperty("webdriver.chrome.driver", "D:\\chromedriver_2.38\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://www.baidu.com/");
}
}
@Test
public void showBaidu(){
System.setProperty("webdriver.chrome.driver", "D:\\chromedriver_2.38\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://www.baidu.com/");
}
}
2.下载firefox驱动
geckodriver.exe,登陆百度
package com.selenium;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
public class seleniumTestDemo1 {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", "D:\\geckodriver-v0.20.0-win64\\geckodriver.exe");
WebDriver driver=new FirefoxDriver();
driver.get("http://www.baidu.com/");
}
}
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
public class seleniumTestDemo1 {
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", "D:\\geckodriver-v0.20.0-win64\\geckodriver.exe");
WebDriver driver=new FirefoxDriver();
driver.get("http://www.baidu.com/");
}
}