Ruby と Watir… Web ドライバーの競合
概要
このリンクから最新バージョンの Ruby Ruby+Devkit 3.2.2.1(x64) をダウンロードしてインストールしました:https://rubyinstaller.org/downloads/
Ruby でコマンド プロンプトを実行し、次のコマンドを実行します。
gem install watir
gem install webdrivers
インタラクティブな Ruby を実行し、次のコマンドを実行します。
require 'Watir'
require 'webdrivers'
以下のようなエラーが発生します。
C:/Ruby32-x64/lib/ruby/3.2.0/rubygems/specification.rb:2295:in `raise_if_conflicts': Unable to activate webdrivers-5.3.1, because selenium-webdriver-4.13.1 conflicts with selenium-webdriver (~> 4.0, < 4.11) (Gem::ConflictError)
from C:/Ruby32-x64/lib/ruby/3.2.0/rubygems/specification.rb:1424:in `activate'
from C:/Ruby32-x64/lib/ruby/3.2.0/rubygems.rb:209:in `rescue in try_activate'
from C:/Ruby32-x64/lib/ruby/3.2.0/rubygems.rb:202:in `try_activate'
from <internal:C:/Ruby32-x64/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:154:in `rescue in require'
from <internal:C:/Ruby32-x64/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:39:in `require'
from (irb):2:in `<main>'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/irb-1.6.2/exe/irb:11:in `<top (required)>'
from C:/Ruby32-x64/bin/irb:33:in `load'
from C:/Ruby32-x64/bin/irb:33:in `<main>'
C:/Ruby32-x64/lib/ruby/3.2.0/rubygems/specification.rb:2295:in `raise_if_conflicts': Unable to activate webdrivers-5.3.1, because selenium-webdriver-4.13.1 conflicts with selenium-webdriver (~> 4.0, < 4.11) (Gem::ConflictError)
from C:/Ruby32-x64/lib/ruby/3.2.0/rubygems/specification.rb:1424:in `activate'
from C:/Ruby32-x64/lib/ruby/3.2.0/rubygems.rb:203:in `try_activate'
from <internal:C:/Ruby32-x64/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:154:in `rescue in require'
from <internal:C:/Ruby32-x64/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:39:in `require'
from (irb):2:in `<main>'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/irb-1.6.2/exe/irb:11:in `<top (required)>'
from C:/Ruby32-x64/bin/irb:33:in `load'
from C:/Ruby32-x64/bin/irb:33:in `<main>'
<internal:C:/Ruby32-x64/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- webdrivers (LoadError)
from <internal:C:/Ruby32-x64/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from (irb):2:in `<main>'
from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/irb-1.6.2/exe/irb:11:in `<top (required)>'
from C:/Ruby32-x64/bin/irb:33:in `load'
from C:/Ruby32-x64/bin/irb:33:in `<main>'
私が何を間違ったのでしょうか?文字通り、手順に従ってインストールする方法を説明します…
Ruby をアンインストールして再インストールし、Ruby のインストール時にプレインストールされたドライバーが原因で競合が発生するのではないかと考え、最初にインストールせずに「Require Webdrivers」を実行してみましたが、何も呼び出されませんでした。
解決策
Selenium はドライバーを直接管理するようになりました (そして webdrivers gem よりも優れています)。そのため、webdrivers gem はもう必要ありません。要件を削除すれば正常に動作します。
詳細と理由については、こちらをご覧ください。 https://translate.google.com/translate?hl=ja&sl=en&tl=ja&u=https://github.com/titusfortner/webdrivers/#update-future-of-this-project