在Chrome自动更新为v65后,我最近将ChromeDriver更新为2.36。
但是在运行测试时我现在正处于异常
之下Starting ChromeDriver 2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91) on port 10482
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: failed to write automation extension zip
(Driver info: chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 218 milliseconds
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
System info: host: '172.16.27.222', ip: '172.16.123.114', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_77'
Driver info: driver.version: ChromeDriver
尝试过chromeOptions& DesiredCapabilties
ChromeOptions o = new ChromeOptions();
o.addArguments("disable-extensions");
o.addArguments("--start-maximized");
ChromeDriver chromeDriver = new ChromeDriver(o);
return chromeDriver;
还试过以下方法:
ChromeDriver chromeDriver = new ChromeDriver(capabilities);
chromeDriver.manage().window().maximize();
答案 0 :(得分:1)
错误说明了一切:
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: failed to write automation extension zip
(Driver info: chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 218 milliseconds
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
System info: host: '172.16.27.222', ip: '172.16.123.114', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_77'
Driver info: driver.version: ChromeDriver
从错误堆栈跟踪中可以清楚地看出 driver.version 未被识别。
您的主要问题是您使用的二进制文件之间的版本兼容性,如下所示:
因此 JDK v8u77 , Selenium Client v3.11.0 , ChromeDriver 版本( v2.36)之间明显不匹配)和 Chrome浏览器版本( v65.0 )
@Test
。如果您打算使用 ChromeDriver 和 Chrome浏览器,同时初始化 WebDriver 实例,而不是使用 ChromeDriver 实现使用 WebDriver 接口,如下所示:
WebDriver chromeDriver = new ChromeDriver(o);
如果您打算最大化浏览器窗口,请使用chromeDriver.manage().window().maximize();
实例,而不是使用ChromeOptions
实例,如下所示:
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
答案 1 :(得分:0)
以下是我使用的论据:
ArrayList<String> args = new ArrayList<String>();
args.add("enable-automation");
args.add("test-type=browser");
args.add("disable-plugins");
args.add("disable-infobars");
args.add("disable-extensions");
options.put("args", args);
我认为你至少需要添加“enable-automation”参数。