要把ChromeDriver放到代码中的文件夹中c://*******Application
public static WebDriver WebDriverRun(WebDriver driver){
// System.setProperty(Dom4jXml.getValue("chromeDriverName"), Dom4jXml.getValue("chromeDriverPath"));
// 设置 chrome 的路径
System.setProperty(
"webdriver.chrome.driver",
"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe");
webdriver = new ChromeDriver(chromeOptions());
// 转型为WebDriver, 统一类型,方便调用异常截图方法
RuntimeServer runtime = new RuntimeServer();
runtime.runtimeDriver(webdriver);
// driver = chromeOptions();
//driver = new FirefoxDriver();
return webdriver;
}
/**
* 禁止chrome弹出忽略网站证书错误提示
* @return
*/
public static ChromeOptions chromeOptions(){
ChromeOptions options = new ChromeOptions();
// DesiredCapabilities capabilities = DesiredCapabilities.chrome();
// capabilities.setCapability("chrome.switches", Arrays.asList("--start-maximized"));
// options.addArguments("--test-type", "--start-maximized");
options.addArguments("--test-type", "--ignore-certificate-errors");
return options;
}