Watir 入门错误
Watir getting started error
我试图开始一个 Watir 项目,为此我创建了一个文件 (test.rb)
require 'watir'
browser = Watir::Browser.new
browser.goto 'google.com'
browser.text_field(title: 'Search').set 'Hello World!'
browser.button(type: 'submit').click
puts browser.title
# => 'Hello World! - Google Search'
browser.closeenter code here
但是当我 运行 (ruby teste.rb) 时,它给了我一个错误
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- watir/loader
(LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/2.0.0/gems/commonwatir-4.0.0/lib/watir.rb:1:in `<top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:144:in `require'
from teste.rb:1:in `<main>'
我已经安装了 watir(gem 安装了 watir)。
有人可以帮助我吗?
谢谢
你需要bundle update
。您不应该看到 commonwatir
gem 与 Watir 6.x
的依赖关系
试试 require "watir-webdriver"
我试图开始一个 Watir 项目,为此我创建了一个文件 (test.rb)
require 'watir'
browser = Watir::Browser.new
browser.goto 'google.com'
browser.text_field(title: 'Search').set 'Hello World!'
browser.button(type: 'submit').click
puts browser.title
# => 'Hello World! - Google Search'
browser.closeenter code here
但是当我 运行 (ruby teste.rb) 时,它给了我一个错误
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- watir/loader
(LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/2.0.0/gems/commonwatir-4.0.0/lib/watir.rb:1:in `<top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:144:in `require'
from teste.rb:1:in `<main>'
我已经安装了 watir(gem 安装了 watir)。 有人可以帮助我吗?
谢谢
你需要bundle update
。您不应该看到 commonwatir
gem 与 Watir 6.x
试试 require "watir-webdriver"