watir测试报告(一)
来源:互联网 发布:软件开发者 编辑:程序博客网 时间:2024/05/01 13:43
本文讲述的是利用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测试报告(一)
- watir测试报告(二)
- watir
- 联通3G试用测试报告(一)上网部分
- jmeter学习笔记(一)-jmeter html测试报告
- mongodb3.0 性能测试报告 一
- 基于ruby+watir的测试应用系列文章(一) 基本原理
- watir-webdriver不得不说的事(一)
- ruby学习一watir常用api总结
- watir安装备忘(Rubygem)
- 测试报告(1)
- 性能测试报告(实例)
- 性能测试报告(实例)
- 测试报告
- 测试报告
- 测试报告
- 测试报告
- 测试报告
- 算法基础
- Oral English in sap
- 分布式系统
- android 多界面应用程序退出的方法
- apache 403错误 You don't have permission to access on this server
- watir测试报告(一)
- UIWebView 使用
- DirectX中使用shader时 SetTechnique弹出runtime error(ESP错误) 的处理
- 设计模式——建造者模式_Builder Pattern
- 无惧Zynga,YCombinator孵化公司LVL6推出Mercenary, Inc
- Android Activity的title的设置
- 程序员技术练级攻略
- 移动互联网
- 期待第1111次访客