23
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Selenium+Chrome75で全てのオプションが効かない

Last updated at Posted at 2019-06-07

表題の件ですが、何故直るのかいまいちはっきりしてませんけど、動かせたので共有しておきます。

参考になったのはここです。

The issue is that Chromedriver 75 now defaults to the webdriver w3c specification compliant mode. W3C does not support browser logs, so neither does the selenium class. You can set w3c to false, or downgrade to chrome 74, but as far as I know there are not plans to add this functionality back in the near future.

「selenium classもサポートしていません」というのがどういう意味なのかはっきりしませんが、こいつのせいでオプションが効いてないようです。

以下のコードを試したら動きました。

Capybara.register_driver "headless_ios11".to_sym do |app|
  Capybara::Selenium::Driver.new(app, browser: :chrome,
    desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome(
      chromeOptions: {
        args: ["--headless", "window-size=375,667", "--incognito", "--user-agent=Mozilla/5.0 (iPhone; CPU iPhone OS 11_2_1 like Mac OS X) AppleWebKit/604.4.7 (KHTML, like Gecko) Version/11.0 Mobile/15C153 Safari/604.1"],
        w3c: false
      }
    )
  )
end

chromeOptionsにw3c: falseを渡すと渡したオプションが有効になります。困っている人いたら試してみてください。

23
13
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?