chrome瀏覽器驅動chromedriver.exe存放在D盤下,代碼如下:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
/*
* chrome瀏覽器驅動存放在D盤下
*/
public class KeywordBrowserChromePath {
public static void main(String[] args) {
//chrome的驅動存存放在D盤下
System.setProperty("webdriver.chrome.driver", "D:\\chromedriver\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://www.baidu.com");
}
}