Cheat Sheet

转载 2012年03月21日 09:31:34

 

Getting Started

Load the Watir library

require 'watir'

Open a browser (default: Internet Explorer)

browser = Watir::Browser.new

Open Browser at the specified URL

browser = Watir::Browser.start("http://google.com")

Go to a specified URL

browser.goto("http://amazon.com")

Close the browser

browser.close

Browser options (IE only)

Speed up execution
(or use the "-b" command line switch)

browser.speed = :fast

Maximize browser window

browser.maximize

Pop browser window to front

browser.bring_to_front

Access an Element

Text box or text area

t = browser.text_field(:name, "username")

Button

b = browser.button(:value, "Click Here")

Drop down list

d = browser.select_list(:name, "month")

Check box

c = browser.checkbox(:name, "enabled")

Radio button

r = browser.radio(:name, "payment type")

Form

f = browser.form(:name, "address")
f = browser.form(:action, "submit")

Link

l = browser.link(:url, "http://google.com")
l = browser.link(:href, "http://google.com")

Table cell in a table (2nd row, 1st column)

td = browser.table(:name, 'recent_records')[2][1]

Manipulate the Element

Click a button or link

b.click
l.click

Enter text in a text box

t.set("mickey mouse")

Enter multiple lines in a multi-line text box

t.set("line 1\nline2")

Set radio button or check box

c.set
r.set

Clear an element

t.clear
c.clear
r.clear

Select an option in a drop down list

d.select "cash"
d.set "cash"

Clear a drop down list

d.clearSelection

Submit a form

f.submit

Flash any element (useful from the watir-console)

e.flash

Check the Contents

Return the html of the page or any element

browser.html
e.html

Return the text of the page or any element

browser.text
e.text

Return the title of the document

browser.title

Get text from status bar.

browser.status
=> "Done"

Return true if the specified text appears on the page

browser.text.include? 'llama'

Return the contents of a table as an array

browser.table(:id, 'recent_records').to_a

Based on the Secret Geek Cheat Sheet and the Scripting Web Tests Cheat Sheet

<!-- -->

相关文章推荐

Pandas Cheat Sheet学习笔记

Pandas 作为python的库,包含易于使用的数据结构,是一个强大数据分析的工具。 Pandas数据结构 Pandas的主要数据结构有Series和DataFrame。Series是一种类似于一维...

Graphical vi-vim Cheat Sheet and Tutorial

Learning vi or vim is not easy. But it doesn't have to be that difficult, either. It is, in any case...
  • goowie
  • goowie
  • 2013年11月18日 16:42
  • 1796

jqMobi指南系列教程是《 jqMobi Javascript Frameworks Cheat Sheet》 的中文版现在改名为app framework

jqMobi指南系列教程是《 jqMobi JavascriptFrameworks Cheat Sheet》 的中文版,详细介绍了jqMobi. jqMobi指南(一):介绍jqMobi组成 ...

恶意文档分析技巧及工具快速参考(Cheat Sheet)

原文网址:http://www.pulog.org/Resources/1299/MD-Cheat-Sheet/     这份快速参考概要的给出了逆向分析恶意文档这些文档(包括:微软...

Ruby Cheat Sheet

Ruby Cheat Sheet Created by Brian Marick and Bret Pettichord for Scripting for Testers tutori...

Git Cheat Sheet

From http://cheat.errtheblog.com/s/git/ Setup ----- git clone clone the repository specified...
  • hansel
  • hansel
  • 2011年05月20日 10:23
  • 2141

大O表示法算法复杂度速查表(Big-O Algorithm Complexity Cheat Sheet)

原文网址:http://bigocheatsheet.com/ Word文档下载:http://download.csdn.net/detail/anshan1984/5583399 ...

Mdadm Cheat Sheet

http://www.ducea.com/2009/03/08/mdadm-cheat-sheet/ Mdadm Cheat Sheet Mdadm is the modern tool mo...

CSS Shorthand Cheat Sheet by Example

转自:http://files.cnblogs.com/wiky/css-shorthand-cheat-sheet.pdf Margin & Padding #div { margin-t...

渗透测试实用Cheat Sheet

[译]Thanks   [原文]AverageSecurityGuy 这里整理了许多渗透测试中实用的TIPS,希望对您有用。PS.仅用于安全渗透测试及学习,禁止非法使用。 共享相关 ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Cheat Sheet
举报原因:
原因补充:

(最多只允许输入30个字)