`
yanzilee9292
  • 浏览: 528246 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Watir get started

 
阅读更多

 

 

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

 

 

 

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]

 

 

 

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

 

 

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

 

 

 

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

 

 

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

 

 

 

 

分享到:
评论

相关推荐

    watir测试框架介绍

    watir测试框架介绍 watir测试框架介绍 watir测试框架介绍

    watir安装包之三 IE watir

    安装命令:gem install watir --local。

    ruby and watir 安装指南

    I am not sure when this started to occur, but the documentation on the site is lacking. answer: 3 down vote accepted On Windows XP (Professional, Version 2002, Service Pack 3, fully pathched) I ...

    watir-1.5.2.gem

    Firefox下载地址:http://www.hacker.cn/Get/gjrj/06102608545293311.shtml,建议装2.0 Gem下载地址:http://rubyforge.org/frs/?group_id=104&release_id=28016,建议装:rubygems-update-1.3.4.gem Firefox插件...

    watir-1.6.5.gem

    Firefox下载地址:http://www.hacker.cn/Get/gjrj/06102608545293311.shtml,建议装2.0 Gem下载地址:http://rubyforge.org/frs/?group_id=104&release_id=28016,建议装:rubygems-update-1.3.4.gem Firefox插件...

    watir语法详解和描述

    watir语法的详细介绍和描述,适合watir初学者。

    watir介绍及安装

    watir介绍及安装

    Watir测试框架介绍

    Watir测试框架介绍、环境配置、API介绍

    自动化测试Watir参考手册

    该文档比较详细地介绍了自动化测试工具watir

    watir-cn中文补丁包

    watir-cn中文语言包 watir-cn中文语言包 watir-cn中文语言包 watir-cn中文语言包 watir-cn中文语言包 watir-cn中文语言包 watir-cn中文语言包 watir-cn中文语言包 watir-cn中文语言包 watir-cn中文语言包 watir-cn...

    watir Web自动化测试框架 api

    Watir 是一个使用 Ruby 实现的开源Web 自动化测试框架,相对于那些庞大的商业工具来说,它很小巧,也很灵活,提供的功能也足够用。最近抽时间试用了一下,感觉还不错,准备下一步在公司推广使用。因为 Watir 的网站...

    Watir自动化测试培训

    公司自动化测试培训ppt,使用语言ruby,自动化测试工具watir,讲解基础api和常用框架

    watir api chm

    watir的api文档,可以离线查阅! chm格式。

    watir简易教程

    Watir全称是“Web Application Testing in Ruby”,发音类似“water”。它是一种基于网页模式的自动化功能测试工具。 Watir是一个Ruby库,使用多版本浏览器进行Web应用程序测试。

    Watir-Webdriver最新安装文件(全)

    压缩包中包含目前2013/01/19最新的安装文件,有rubyinstaller-1.9.2-p136、DevKit-tdm-32-4.5.1-20101214-1400-sfx、rubygems-1.8.24、watir-4.0.2、watir-webdriver-0.6.2等文件,并附上简略安装说明。

    Watir图文教程

    Watir图文教程 ppt材料 全英文 但是很容易看懂

    ruby+watir安装包,安装步骤

    2.本地安装watir-1.4.1.gem,执行gem install watir-1.4.1.gem -l 3.本地安装rubygems-update-1.3.4.gem,执行 gem install rubygems-update-1.3.4.gem 4.更新rubygems,执行update_rubygems (这一步先忽略,有影响...

Global site tag (gtag.js) - Google Analytics