Selenium webdriver 不会退出 Chrome 驱动程序

nai*_*avs 6 java selenium selenium-chromedriver selenium-webdriver

我正在使用Selenium webdriver但它不会退出chrome并且chrome正确驱动。一些过程沉闷的赛跑者。

退出 chrome 的代码:

 driver.quit();
Run Code Online (Sandbox Code Playgroud)

启动 chrome 的代码:

 System.setProperty("webdriver.chrome.driver","/<path to chrome driver>/chromedriver");
 ChromeOptions options = new ChromeOptions();
 options.setBinary(new File("/<path to chrome >/google-chrome"));
 driver = new ChromeDriver(options);
Run Code Online (Sandbox Code Playgroud)

Chrome 驱动程序版本:2.9.248304 Chromium 版本:40.0.2214.115 Selenium 版本:2.32 操作系统:Linux java.version:1.7.0_71

提前致谢,奈拉

aho*_*olt 5

您是否在finally块中执行driver.quit()?

System.setProperty("webdriver.chrome.driver","/<path to chrome driver>/chromedriver");
ChromeOptions options = new ChromeOptions();
options.setBinary(new File("/<path to chrome >/google-chrome"));
driver = new ChromeDriver(options);
try
{
    //automated steps
}
finally
{
    driver.quit();
}
Run Code Online (Sandbox Code Playgroud)


nai*_*avs -10

问题在于 driver.quit() 方法仅适用于 Chrome。驱动程序退出无法正常工作,它没有杀死 chrome 的所有进程(包括子进程)。我做了什么。我更改了 Selenium jar 代码来解决我的项目的问题,不幸的是,由于项目规则不允许共享任何类型的代码,我无法共享我的代码。

  • 当然,您受到知识产权协议的约束。但是,如果你有逻辑的话,解释一下逻辑并没有什么错。那不是IP。 (12认同)