开源Web自动化测试框架

Watir 是一个使用 Ruby 实现的开源Web 自动化测试框架,相对于那些庞大的商业工具来说,它很小巧,也很灵活,提供的功能也足够用。最近抽时间试用了一下,感觉还不错,准备下一步在公司推广使用。
  因为 Watir 的网站上用户手册、示例代码以及 FAQ 都维护的不错,所以已有的东西我就不重复了,在这里简单介绍一下,如果同行们有兴趣,可以一起研究一下。
   1. 脚本示例
  先丢一段脚本给大家看看使用 Watir 来书写脚本是多么的方便。下面的例子是 Watir 自带的一段测试 Google 的搜索功能的脚本,不过我只保留了最主要的部分,以使它看起来更简洁一些:
require 'watir'     # the watir controller

     # open the IE browser

     ie = Watir::IE.new

     # Step 1: go to the test site: [url]http://www.google.com[/url]

     ie. goto ([url]http://www.google.com[/url])

     # Step 2: enter 'pickaxe' in the search text field

     ie.text_field(: name, "q"). set("pickaxe")             # q is the name of the search field

     # Step 3: click the 'Google Search' button

     ie.button(: name, "btnG").click                                 # "btnG" is the name of the Search button

     # Actual Result: Check that the 'Programming Ruby' link appears on the results page    

     if    ie.contains_text("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

     # End of test: Google search

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值