专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Ruby/Rails

已经安装好ruby和watir为什么运行出错?解决方法

发布时间:2011-06-29 18:43:43 文章来源:www.iduyao.cn 采编人员:星星草
已经安装好ruby和watir为什么运行出错?
我从 http://rubyforge.org/frs/?group_id=167下载里 1.8.6-27 版本并安装好,接下来通过网络安装了watir
命令是: gem install watir 
然后从网上摘了一段测试代码:

#-------------------------#
# Demo test for the Watir controller.
#
# Simple Google test written by Jonathan Kohl 10/10/04.
# Purpose: to demonstrate the following Watir functionality:
# * entering text into a text field,
# * clicking a button,
# * checking to see if a page contains text.
# Test will search Google for the "pickaxe" Ruby book.
#-------------------------#
# the Watir controller
require "watir"
# set a variable
test_site = "http://www.google.com"
#open the IE browser
ie = Watir::IE.new
# print some comments
puts "Beginning of test: Google search."
puts " Step 1: go to the test site: " + test_site
ie.goto test_site
puts " Step 2: enter 'pickaxe' in the search text field."
ie.text_field(:name, "q").set "pickaxe" # "q" is the name of the search field
puts " Step 3: click the 'Google Search' button."
ie.button(:name, "btnG").click # "btnG" is the name of the Search button
puts " Expected Result:"
puts " A Google page with results should be shown. 'Programming Ruby' should be high on the list."
puts " Actual Result:"
if ie.text.include? "Programming Ruby" 
puts " Test Passed. Found the test string: 'Programming Ruby'. Actual Results match Expected Results."
else
puts " Test Failed! Could not find: 'Programming Ruby'." 
end
puts "End of test: Google search."


在SciTE里运行后就出现:
>ruby google_search.rb
google_search.rb:12:in `require': no such file to load -- watir (LoadError)
from google_search.rb:12
>Exit code: 1
这是为什么?是没有安装好watir?

------解决方案--------------------
一起学习了
http://www.ruby-lang.org.cn/forums/thread-520-1-17.html
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: