本文讲述的是利用watir来生成html报告。

其一: 使用test/unit, 这样结构上看其里比较清晰。

其二: 订制html样式, 这样每次只要套用就可以了。

其三: 本文尚有不足之处。 需不断修改, 以为己用。

require 'test/unit'

require 'watir'

require 'html.class'

class Google_search_test < Test::Unit::TestCase
def setup
     @browser_type = 'IE'
     #~ browser_type = 'Firefox'
     @site = "www.google.com"
     @test_environment = 'QA'
     # initialize HTML report
     @html = HTMLReport.new()
     # createReport(reportName, header, browser_type)
     @report = @html.createReport('google_search', 'Google Search', @browser_type)
end

def test_001
#this method can be set comm method.
  if @browser_type == 'IE'
     @browser = Watir::IE.new
     @browser.goto @site

elsif @browser_type == 'Firefox'
     Watir::Browser.default = 'firefox'
     @browser = Watir::Browser.start(@site)
  end
 
  ######################################
  test_case = @html.newTestName('Verify controls')
  ######################################
 
  test = 'Step 1: Check search text field'
  @html.add_to_report(@browser.text_field(:name, 'q').exists?, test, 'PASS: Located search text field', 'FAIL: Unable to locate search field')
 
  test = 'Step 2: Check Google Search button'
  @html.add_to_report(@browser.button(:name, 'btnG').exists?, test, 'PASS: Located Google Search button', 'FAIL: Unable to locate Google Search button')
 
  test = 'Step 3: Check Feeling Lucky button'
  @html.add_to_report(@browser.button(:name, 'btnI').exists?, test, 'PASS: Located Feeling Lucky button', 'FAIL: Unable to locate Feeling Lucky button')
 
  ######################################
  test_case = @html.newTestName('Perfom Watir search')
  ######################################
 
  @browser.text_field(:name, 'q').set 'Watir'
  @browser.button(:name, 'btnG').click
  test = 'Step 1: Check valid search results (1)'
  @html.add_to_report(@browser.text.include?('Babysteps in WATIR'), test, 'PASS: Located text "Babysteps in WATIR"', 'FAIL: Unable to locate text "Babysteps in WATIR"')
 
  test = 'Step 2: Check valid search results (2)'
  @html.add_to_report(@browser.text.include?('Project Info'), test, 'PASS: Located text "Project Info"', 'FAIL: Unable to locate text "Project Info"')
 
  test = 'Step 3: Check for invalid search results'
  @html.add_to_report(@browser.text.include?('Suez Canal'), test, 'PASS: Did not locate text "Suez Canal"', 'FAIL: Found text "Suez Canal"')

end

def teardown
 # teardown
  #@browser.close
  @html.finishReport(@report, @browser_type, @test_environment)
  rescue => e
    puts $!
    puts e.backtrace
    @html.finishReport(@report, @browser_type, @test_environment)
    #~ @browser.close
end

end

watir测试报告(一)相关推荐

  1. 建立企业级产品测试报告体系(概述)

    基本上每个制造企业都有自己定制得测试报告.这种报告通常是提供给客户作为数据参考,甚至会导入数据库进行调测使用. 所以,建立统一的测试报告中心进行数据和报告的管理是有必要的. 1.1测试报告体系的愿景 ...

  2. 全球SDN测试认证中心发布OpenDaylight测试报告

    随着软件定义网络(Software Defined Network, SDN)商业部署速度地加快,关乎整个SDN 网络性能表现的控制平面核心组件--SDN 控制器也越来越成为网络用户关心的焦点.日前, ...

  3. Robotium测试报告的生成方法(上)

    7.1 使用junit-report生成报告 这个是参考网上的:http://www.xuebuyuan.com/2148574.html,经我个人验证是可行的方法,网上写的挺详细的,不过有些不太清楚 ...

  4. python自动生成测试报告步骤_生成HTMLTestRunner测试报告的操作步骤——Python+selenium自动化...

    HTMLTestRunner是Python标准库的unittest模块的一个扩展,具体操作如下 1.安装 环境:Window8 步骤:1)http://tungwaiyip.info/software ...

  5. 测试报告-1.1组成和要点

    个人知识脑图总结 1.测试报告组成,结合工作总结 转载于:https://www.cnblogs.com/bf-blackfish/p/10263743.html

  6. 给接口自动化测试框架增色,实现企业微信测试报告

    作者在新项目中搭建了python+requests+unittest+HTMLTestRunner接口自动化测试框架,通过修改配置文件实现环境隔离,一份脚本即可在不同的环境执行接口测试用例. 但是没有 ...

  7. 阿里软件测试工程师手把手教学——自动化测试报告太丑,怎么办?

    TestNG的报告太难看了?测试结果维度显示受限?无法确定用例的优先级?查看错误信息不方便吗? Allure测试报告框架帮助您轻松实现"高"报告呈现.本文通过实例演示了如何将All ...

  8. emqx速度_EMQX-3.0性能测试报告-ReadtheDocs.PDF

    EMQX-3.0性能测试报告-ReadtheDocs.PDF EMQX-3.0性性性能能能测测测试试试报报报告告告 Release 3.0.4 杭杭杭州州州 云云云科科科技技技有有有限限限公公公司司司 ...

  9. 第九次作业-测试报告和用户使用手册

    第九次作业-测试报告和用户使用手册 测试报告 测试原则:所有的测试都应追溯到用户需求.测试必须基于"质量第一"的思想去开展各项工作. 网站计划应该在测试工作真正开始前的较长时间内进 ...

最新文章

  1. Scala函数式编程(三) scala集合和函数
  2. python基础代码-python基础,python基础代码大全
  3. 茶香账簿小程序开发进度(1)
  4. Power BI 可视化交互/视觉对象交互
  5. 2020年_Jsp Jstl 学习笔记
  6. 小米空调来了,意外的是还一起来了一个马桶盖
  7. UNIX编程艺术 UNIX哲学
  8. Hibernate各个版本的下载地址
  9. C6678/C6657+ZYNQ/K7/A7 FPGA+AD+北斗的软硬件设计方案
  10. 文档数据库-MongoDB
  11. word如何设置页眉横线的磅数
  12. Python爬虫120例之案例58,手机APP爬虫,“武器库”的准备and皮皮虾APP的测试
  13. 蝴蝶效应---。。。
  14. Vuepress Reco主题备忘
  15. SLAM代码(SVO ros )
  16. 看片会员php源码,会员碎片 · THINKPHP插件 · 看云
  17. 在windows生成SSH秘钥连接linux远程主机
  18. kafka之broker
  19. pdf转换成word转换器在线哪个最好
  20. http方法有哪些?get、post、put、delete,为什么一般只用过get和post?什么时候用put、delete,为什么没用过

热门文章

  1. ubuntu定时执行python脚本_Ubuntu 每天定时开关机并运行指定脚本
  2. 2020考研计算机(408)考试大纲原文以及分析
  3. 北大CSAPP期末题
  4. java对接自动充电桩_充电桩自动对接装置的制作方法
  5. 移动端 简易的table表格
  6. 再谈 Go 语言在前端的应用前景
  7. linux下网卡参数配置,linux网卡配置参数
  8. 单片机蜂鸣器音乐播放
  9. php编程模块英文缩写_php的英文全称是什么
  10. centos使用yum安装xtrabackup