尝试执行我的 ruby 脚本时,我收到以下错误消息
C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/dependency.rb:308:in `to_specs': Could
not find 'rubyzip' (~> 1.0) among 14 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=C:/Users/me/.gem/ruby/2.4.0;C:/Ruby24-
x64/lib/ruby/gems/2.4.0', execute `gem env` for more information
from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/specification.rb:1442:in
`block in activate_dependencies'
from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/specification.rb:1431:in
`each'
from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/specification.rb:1431:in
`activate_dependencies'
from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems/specification.rb:1413:in
`activate'
from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems.rb:220:in `rescue in
try_activate'
from C:/Ruby24-x64/lib/ruby/2.4.0/rubygems.rb:213:in `try_activate'
from C:/Ruby24-
x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:126:in `rescue in
require'
from C:/Ruby24-
x64/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:40:in `require'
from setupscript.rb:2:in `<main>'
我运行 gem env 并返回以下内容
RubyGems Environment:
- RUBYGEMS VERSION: 2.6.11
- RUBY VERSION: 2.4.1 (2017-03-22 patchlevel 111) [x64-mingw32]
- INSTALLATION DIRECTORY: C:/Ruby24-x64/lib/ruby/gems/2.4.0
- USER INSTALLATION DIRECTORY: C:/Users/me/.gem/ruby/2.4.0
- RUBY EXECUTABLE: C:/Ruby24-x64/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/Ruby24-x64/bin
- SPEC CACHE DIRECTORY: C:/Users/me/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: C:/ProgramData
- RUBYGEMS PLATFORMS:
- ruby
- x64-mingw32
- GEM PATHS:
- C:/Ruby24-x64/lib/ruby/gems/2.4.0
- C:/Users/me/.gem/ruby/2.4.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- :sources => []
- REMOTE SOURCES:
- SHELL PATH:
- C:Program FilesConEmuConEmuScripts
- C:Program FilesConEmu
- C:Program FilesConEmuConEmu
- C:ProgramDataOracleJavajavapath
- C:Windowssystem32
- C:Windows
- C:WindowsSystem32Wbem
- C:WindowsSystem32WindowsPowerShellv1.0
- C:Program Files (x86)Oracleinstantclient_11_2
- C:Program Files (x86)WebExProductivity Tools
- C:Program Filesnodejs
- C:Program Files (x86)SilkSilkTest
- C:Program Files (x86)SilkSilkTestnggui
- C:Program FilesMicrosoft SQL Server130ToolsBinn
- C:Program Filesdotnet
- C:Ruby24-x64bin
C:\Users\me\AppData\Local\Microsoft\WindowsApps,C:\Users\me\Documents\Automation\SeleniumBrowserDrivers\IEDriverServer_Win32_3.4.0\ - C:\Users\me\AppData\Local\Programs\Fiddler - C:\Users\me\AppData\Roamingpm">
我的脚本是 seleniumhq 页面上的示例 ruby 脚本。
require 'rubygems'
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :IE
driver.get "http://google.com"
element = driver.find_element :name => "q"
element.send_keys "Cheese!"
element.submit
puts "Page title is #{driver.title}"
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
wait.until { driver.title.downcase.start_with? "cheese!" }
puts "Page title is #{driver.title}"
driver.quit
谢谢 斯科特
由于某种原因,我无法安装rubyzip。 我需要
- 将 Gem 下载到我的系统中
- 导航到文件夹
- 执行 gem install --force --local *.gem
当我执行上述步骤时,gem 已安装。