發(fā)文章
發(fā)文工具
撰寫
網(wǎng)文摘手
文檔
視頻
思維導(dǎo)圖
隨筆
相冊
原創(chuàng)同步助手
其他工具
圖片轉(zhuǎn)文字
文件清理
AI助手
留言交流
Load the Watir library
require 'watir'
Open Internet Explorer at the specified URL
$browser = Watir::IE.start("http://google.com") $browser = Watir::IE.start "http://google.com"
Attach to an existing browser, raising an exception if it isn't found
$browser = Watir::IE.attach(:url, "http://www.google.com") $browser = Watir::IE.attach(:title, "Google")
Attach to an existing browser, returning nil if it isn't found
$browser = Watir::IE.find(:title, "Google") $browser = Watir::IE.find(:url, "http://www.google.com")
Speed up execution (or use the "-b" command line switch)
$browser.speed = :fast
Close the browser
$browser.close
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")
Table cell in a table (2nd row, 1st column)
td = $browser.table(:name, 'recent_records')[2][1]
Click a button or link
b.click l.click
Enter text in a text box
t.set("mickey mouse") t.set "mickey mouse"
Enter multiple lines in a multi-line text box
t.set("line 1\nline2") 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("Hey!") d.select "Hey!"
Clear a drop down list
d.clearSelection
Submit a form
f.submit
Flash any element (useful from the watir-console)
e.flash
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
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
來自: weicat > 《我的圖書館》
0條評論
發(fā)表
請遵守用戶 評論公約
軟件測試(網(wǎng)頁自動化測試實(shí)現(xiàn))
ie = Watir::IE.new.Ruby : 因?yàn)槭鞘褂?Ruby 實(shí)現(xiàn)的,腳本也是 Ruby 的腳本,所以需要在本機(jī)安裝 Ruby。Watir : 可以點(diǎn)擊從這里下載,我下載的是 Watir 1.4 ,是一個.zip 文件,解壓縮以后執(zhí)行 install...
HTML5學(xué)習(xí)資源整理-建站789-讓每個站長建站更輕松
Easily center text vertically, with SVG! | Lea Verou<div>SVG圖中 text元素的居中顯示方法總結(jié)</div>
Easily center text vertically, with SVG!| Lea VerouSVG圖中 text元素的居中顯示方法總結(jié)。You don’t need to change anything on the parent HTML elementDegrades gracefully in non-SVG browsers...
R語言 | 正則表達(dá)式 Cheat Sheet
R語言 | 正則表達(dá)式 Cheat Sheet.
40+精彩的HTML5實(shí)例和教程
40+精彩的HTML5實(shí)例和教程。One page overview of HTML5 – very useful and with good HTML5 examples!35 Cool HTML5 Games。Graphical...
Emulating Fixed Positioning
An absolutely positioned element in the document will be positioned relative to the closest positioned ancestor, or the root element if no such ancestor exists.Well, those browsers suppor...
Python Cheat Sheet
Like lists Python strings are a sequence type so many list commands also work with strings.num = input( "Enter a number between 1 and 100: ")while num <1 or num >100: prin...
CSS Cheat Sheet - CSS - ILoveJackDaniels.com
CSS Cheat SheetPosted in Cheat Sheets, CSS on April 30, 2005 The CSS cheat sheet is designed to act as a reminder and reference sheet, listing all selectors (as of CSS 2.1) and properties...
A Great Vim Cheat Sheet
A Great Vim Cheat SheetA Great Vim Cheat Sheet.If you can’t paste, it’s probably because vim was not built with the system clipboard option. To check, run vim --version and see if +clip...
微信掃碼,在手機(jī)上查看選中內(nèi)容