2017-08-02 90 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");