我已从此链接下载并安装了最新版本的 Ruby Ruby+Devkit 3.2.2.1(x64):https://rubyinstaller.org/downloads/
使用 Ruby 运行命令提示符并运行:
“gem 安装 watir” “gem 安装网络驱动程序”
运行交互式 Ruby,然后运行:
“需要‘Watir’” “需要‘网络驱动程序’
并获得如下论文:
C:/Ruby32-x64/lib/ruby/3.2.0/rubygems/specation.rb:2295:在
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
激活'
来自 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'
来自内部: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'
来自 (irb):2:in <main>' from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/irb-1.6.2/exe/irb:11:in
load' from C:/Ruby32-x64/bin/irb:33:in
'
C:/Ruby32-x64/lib/ruby/3.2.0/rubygems/specification.rb:2295:在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
激活'
来自 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'
来自内部:C:/Ruby32-x64/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb:39:in require' from (irb):2:in
'
来自 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'
来自 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': 无法加载此类文件 -- webdrivers (LoadError)
来自内部:C:/Ruby32-x64/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb:85:in require' from (irb):2:in
'
来自 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'
来自 C:/Ruby32-x64/bin/irb:33:in `'
我做错了什么?严格按照说明一步步安装...
我尝试卸载并重新安装 Ruby,然后运行“Require Webdrivers”而不先安装它们,因为我认为冲突可能是由于安装 Ruby 时预装的一些驱动程序造成的,但没有调用任何内容。
Selenium 现在直接管理驱动程序(比 webdrivers gem 更好),因此您不再需要 webdrivers gem。删除这个要求就可以了。
详细信息和原因的讨论可以在这里找到: https://github.com/titusfortner/webdrivers/#update-future-of-this-project