selenium 启动 chrome浏览器
1、下载ChromeDriver驱动包(下载地址: http://chromedriver.storage.googleapis.com/index.html?path=2.7/);
2、指定ChromeDriver所在位置(System.setProperty("webdriver.chrome.driver", "ChromeDriver的位置");)
3、 ChromeOptions options = new ChromeOptions(); //通过配置参数禁止data;的出现
4、 options.addArguments("--user-data-dir=C:/Users/Administrator/AppData/Local/Google/Chrome/User Data/Default");
//通过配置参数删除“您使用的是不受支持的命令行标记:--ignore-certificate-errors。稳定性和安全性会有所下降。”提示
options.addArguments("--start-maximized", "allow-running-insecure-content", "--test-type");
driver = new ChromeDriver(options);
driver.get("http://www.baidu.com");
return driver;
5、public static void main(String[] args) {
getDriver();
}
}
能启动起浏览器了,还是打不开http://www.baidu.com ---------------查看百度说是可能浏览器版本太高导致
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2017年12月1日:
修改了谷歌浏览器版本为44 selenium为2.53.1 --------------------------成功

浙公网安备 33010602011771号