• 开源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

  • 相关阅读:
    目标需要分解,行动需要激励
    无助和愤怒都有
    一文搞懂MySQL事务的隔离性如何实现|MVCC
    面试官:请分析一条SQL的执行
    浅谈最长公共子序列引发的经典动态规划问题
    一篇文章带你搞懂InnoDB的索引|结合样例
    Docker
    mac上软件闪退找到错误原因
    前端面试题整理——webpack相关考点
    前端面试题整理——React考点和回答
  • 原文地址:https://www.cnblogs.com/tester2test/p/1283397.html
Copyright © 2020-2023  润新知