Watir Cheat Sheet
来源:互联网 发布:猎杀潜航4修改数据 编辑:程序博客网 时间:2024/05/16 01:33
Getting Started with Watir
require 'watir'
Load the Watir library
ie = Watir::IE.start('http://localhost:8080')
Start IE using the local timeclock server.
ie.close
Close IE.
ie = Watir::IE.attach(:title, 'title')
Attach to an existing IE window, so you can drive it with Watir.
Manipulating Controls with Watir
ie.text_field(:name, 'name').set('value')
Set the text field specified name specified value.
ie.button(:value, 'value').click
Click the button with the specified value (label)
ie.button(:name, 'name').click
Click the button with the specified name.
ie.checkbox(:name, 'name').set
Check the check box named "name". (Uncheck: clear)
ie.object(:attribute, 'name').flash
Cause the specified control to flash.
A Special Testing Function For Timeclock
require 'toolkit/testhook'
ensure_no_user_data 'name'
Delete any database records for the named user.
Accessing Page Contents with Watir
ie.contains_text('text')
Return true if the current page has the specified text somewhere on the page. Otherwise, false.
ie.title
Return the title of the current page.
ie.html
Return all the HTML in the body of the page
ie.table(:id, 'recent_records).to_a
Return an array containing the text in the table's rows and columns.
ie.table(:id, 'recent_records')[2][1].text
Return the text from the first column of the second row of the table id'd 'recent_records.
Assertions
assert_equal(expected, test_method)
Test whether the expected value matches the actual value returned by the test method
assert_match(regexp, test_method)
Test whether the regular expression matches the actual value returned by the test method.
assert(expression)
Test whether the expression is true.
- Watir Cheat Sheet
- Cheat Sheet
- Cheat Sheet
- 关于“cheat sheet”
- regular expressions cheat sheet
- Vim Cheat Sheet
- vi vim cheat sheet
- Rails Migration Cheat Sheet
- WinDbg / SOS Cheat Sheet
- PHP Cheat Sheet
- SQL Injection Cheat Sheet
- sql injection cheat sheet
- Input Validation Cheat Sheet
- Git Cheat Sheet
- DBA cheat sheet
- Mdadm Cheat Sheet
- Cheat Sheet of Nmap
- Session Management Cheat Sheet
- JVM内存的设置的原理
- 单元测试的基本方法
- 多线程和函数里的静态变量
- 在用toad执行oracle时发生的错误ORA-01403: 未找到数据
- ACL基本原理与配置
- Watir Cheat Sheet
- 分享一个UML类图的图示样例
- 当“山寨文化”风行网络,我们是追捧还是打杀? Simulated Culture is largely emerging on the internet, and should we follow or force it our?
- 在asp.net 2.0中使用SqlBulkCopy类迁移数据
- js控制框架
- Windows 2003服务器集群配置
- DirectX的一点小知识
- 控件工具栏不能自动弹出怎么办
- 基于Hibernate3.2 Hibernate tools 的使用