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


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

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

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を渡すと渡したオプションが有効になります。困っている人いたら試してみてください。