2017-08-02 2 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

maximize関数を使用していますか? – 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 by ChromeDriver

ChromeOptions options = new ChromeOptions(); 
options.addArguments("start-maximized"); 
関連する問題