19
7

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 3 years have passed since last update.

capybara + seleniumの設定でdesired_capabilities/options属性がDEPRECATIONになった

Posted at

遭遇したWARNING

ruby3.0 対応のため selenium-webdriver4.0.0.beta3 にアップデートしたところ、次のような DEPRECATION WARNING が発生しました。

[DEPRECATION] [:desired_capabilities] :desired_capabilities as a parameter for driver initialization is deprecated. Use :capabilities with an Array value of capabilities/options if necessary instead.

関連するPRはこちらのようです。

要約すると、 :desired_capabilities 属性と :options 属性をどう使いわければよいか判断に迷うので、 :capabilities 属性に統一するとのことです。

Capybaraの設定

以下は、Capybaraの設定の修正例です。

Capybara.register_driver :remote_chrome do |app|
  url = 'http://chrome:4444/wd/hub'
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
    'goog:chromeOptions' => {
      'args' => ['headless', 'disable-gpu', 'window-size=1920,1080'],
    },
  )
-  Capybara::Selenium::Driver.new(app, browser: :remote, url: url, desired_capabilities: capabilities)
+  Capybara::Selenium::Driver.new(app, browser: :remote, url: url, capabilities: capabilities)
end

これで、WARNINGが発生しなくなりました。

19
7
0

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
19
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?