2017-08-02 44 views
0

无法运行无头测试模式模式;它似乎不是一个片段的问题,因为我以不同的方式尝试它,结果是一样的。未知错误:无法自动扩展

caps = Selenium::WebDriver::Remote::Capabilities.chrome(chromeOptions: { binary: "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome", 
                      args: [ "--headless" ]}) 
    @driver = Selenium::WebDriver.for :chrome, desired_capabilities: caps 

错误

unknown error: cannot get automation extension 
from unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html 
    (Session info: headless chrome=59.0.3071.115) 
    (Driver info: chromedriver=2.31.488774 (7e15618d1bf16df8bf0ecf2914ed1964a387ba0b),platform=Mac OS X 10.12.3 x86_64) (Selenium::WebDriver::Error::UnknownError) 

Chrome browser: 59.0.3071.115 (latest)

Chrome driver: chromedriver=2.31.488774 (latest)

Language used: Ruby

+0

你使用任何最大化功能? – Madhan

+0

啊,那是小人......感谢马丹;你能否在这篇文章中回答相同的问题 –

回答

1

这是chromedriver一个已知的问题。正如github

This is a long standing issue with Chromedriver. The window resizing doesn't work with the chromedriver and the community is silent on this bug fix. If the resizing is not critical for your tests, I would suggest you avoid the manage() method altogether and use a workaround of having your browser window always maximized using the ChromeOptions object at the launch of your chromedriver instantiation.

提到虽然它不是发生在每个人,这个问题仍然存在。它主要是通过更新铬或镀铬马达到最新版本解决(仍然不会为大多数人工作)

所以最好不要使用最大化或调整铬的活动。但是,如果你想,你可以去ChromeOptions建议通过ChromeDriver

ChromeOptions options = new ChromeOptions(); 
options.addArguments("start-maximized"); 
相关问题