zoukankan      html  css  js  c++  java
  • 开源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: http://www.google.com

       ie.goto (http://www.google.com)

       # 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

  • 相关阅读:
    毕业设计:专业填写格式
    关于《毕业设计指导记录》的建议
    毕业设计通知
    毕业设计答辩:幻灯片内容制作要点
    Latex 模版生成会议论文 不显示Keywords,而是显示 Index Terms- ,改成Keywords 方法
    mysql information_schema
    C# odbc
    cwRsync 配置文件详解
    Rsync
    openssl rsa 私钥 PKCS8私钥 公钥
  • 原文地址:https://www.cnblogs.com/tester2test/p/1283397.html
Copyright © 2011-2022 走看看