Dogman
-
安装Ruby和Watir - [RAW]
2008-06-25
版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://zlfoxy.blogbus.com/logs/23566425.html
1.首先是要下载ruby安装包。点击这里进入下载页,我选的是1.8.6-26 Final Release。
2.执行刚才下载的安装包。最好是装在系统盘的根下(比如C:\ruby)。相当傻瓜式的next安装。不详解。(中间有个选择组件的步骤,保持默认即可)。
3.安完了。下面开始升级。保持网络连接,暂时关掉防火墙。
运行下面2个命令:
gem update --system
gem install watir第一个是对Rubygems升级,第二个是对安装watir。这两个过程都是要通过网络的。我可能是rp不好从来没执行这2个命令成功过(不过公司的倒是成功了,奇怪),详见我在JavaEye上的提问。
如果你的rp像我一样搓,可以考虑以下方案:
下载最新版本的Rubygems和watir的gem进行手动升级。
4.假设前面这3步都完成了,那柳暗花明的一刻终于来到了。
打开SciTE这个程序,一个极其简练的编辑器呈现在我们面前。
敲一行 puts “Hello World!" 保存为helloworld.rb。
然后按下F5,右侧的OutPut应该会显示:
>ruby google.rb
hello
>Exit code: 0好,然后把下面这一堆代码复制进去。我略微改动了一些地方。其实这是一个别人写的demo。这就是用Watir来进行页面测试的脚本。按F5可以执行下。
#-------------------------------------------------------------#
# 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/"
content = "51Testing"
#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 'watir' in the search text field."
ie.text_field(:name, "q").set "watir" # "q" is the name of the search field
puts " Step 3: click the 'Google Search' button."
ie.button(:type, "submit").click # "submit" is the type of the Search button
puts " Expected Result:"
puts " A Google page with results should be shown. '#{content} ' should be high on the list."
puts " Actual Result:"
if ie.text.include? "#{content}"
puts " Test Passed. Found the test string: '#{content} '. Actual Results match Expected Results."
else
puts " Test Failed! Could not find: '#{content} '."
end
puts "End of test: Google search."随机文章:
将RAW整合到Eclipse 2008-06-25ruby+Watir web测试 2008-06-25JMeter用户手册第7节(建立一个数据库测试计划) 2008-03-10JMeter第6节(建立一个高级的测试计划) 2008-03-10JMeter 第5节(建立一个web测试计划) 2008-03-09
收藏到:Del.icio.us






