我被Chrome浏览器抛出了一种非常不寻常的错误
当我尝试使用以下代码行最大化chrome时
driver.manage().window().maximize();
我低于错误
org.openqa.selenium.WebDriverException: unknown error: cannot get automation extension from unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html (Session info: chrome=57.0.2987.110) (Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 6.3.9600 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 10.05 seconds
通过本示例,我做了以下事情
1. Updated Chrome driver to latest i.e 2.28 for my Chrome version 57.0.2987.110 (64-bit) 2. uninstalled and re-installed Chrome 3. did a project build up in Eclipse even created a new workspace
但是没有帮助,所以我用了
ChromeOptions options = new ChromeOptions(); options.addArguments("start-maximized"); driver = new ChromeDriver();
它可以正常工作,Chrome驱动程序没有显示任何错误, 但是 每当我执行一段代码(例如填写表格或单击某个按钮)后,一段时间后仍然会抛出上述错误。
通常,您看到的原因 WebDriverException: unknown error: cannot get automation extension 可能很多。看到此异常的两种最常见的情况是:
WebDriverException: unknown error: cannot get automation extension
chromedriver
Chrome Browser
ChromeDriver Release Notes
ChromeOptions.addArguments("start-maximized");
根据您的问题,异常似乎来自上述情况之一。
试用以下步骤:
CCleaner
OS
ChromeOptions options = new ChromeOptions();
options.addArguments(“test-type”); options.addArguments(“start-maximized”); options.addArguments(“disable-infobars”); options.addArguments(“–disable-extensions”); driver = new ChromeDriver(options);
您的程序应与最新的chrome驱动程序2.28和Chrome版本57.0.2987.110(64位)一起使用。让我知道这是否对您有帮助。