watir 初学一 (Page Elements >simple)
上一篇 /
下一篇 2011-04-06 23:24:39
/ 个人分类:watir
http://wiki.openqa.org/display/WTR/Tutorial
=======Buttons=======
html buttons
the tag in the HTML source:
<input type="button"id="one"name="clickme"value="Click Me">
ie.button(:id, "one").click
ie.button(:name, "clickme").click
ie.button(:value, "Click Me").click
image buttons
the tag in the HTML source:
<input type="image"src="images/doit.gif">
ie.button(:src, /doit/).click
========Checkboxes=========
Check Me:
the tag in the HTML source:
Check Me:<input type="checkbox"id="one"name="checkme">
id attribute
ie.checkbox(:id, "one").set #选中
e.checkbox(:id, "one").clear #不选中
name attribute
ie.checkbox(:name, "checkme").set
ie.checkbox(:name, "checkme").clear
==========Links================
Pickaxe
the HTML source:
<a href="http://pragmaticprogrammer.com/titles/ruby/"id="one"name="book">Pickaxe</a>
id attribute
ie.link(:id, "one").click
name attribute
ie.link(:name, "book").click
text
ie.link(:text, "Pickaxe").click
href attribute
ie.link(:href, "http://pragmaticprogrammer.com/titles/ruby/").click
=============Radio Button=================
Click Me:
the tag in the HTML source:
<input type="radio"name="clickme"id="one">
id attribute
ie.radio(:id, "one").set
ie.radio(:id, "one").clear
name attribute
ie.radio(:name, "clickme").set
id.radio(:name, :clickme").clear
============selection boxes============
tag in the HTML source:
<select id="one"name="selectme"><option></option><option>Web Testing</option><option>in Ruby</option><option>is fun</option></select>
id attribute
id.select_list(:id, "one").set("is fun")
name attribute
id.select_list(:mame, "selectme").set("is fun")
selection box methods
ie.select_list(:id, "one").clearSelection #clear a select box item using the id attribute
contents = ie.select_list(:id, "one").getAllContents #get the contents of a select list
select multiple
What you see in the web browser:
the tag in the HTML source:
<select id="one"name="selectme"multiple="multiple"><option></option><option>Web Testing</option><option>in Ruby</option><option>is fun</option></select>
ie.select_list(:id, 'one').set('Web Testing')
ie.select_list(:id, 'one').set('in Ruby')
ie.select_list(:id, 'one').set('is fun') #select every option in the select list ie.select_list(:id, 'one').clearSelection # clear everything
============text fields=====================
the tag in the HTML source:http://wiki.openqa.org/display/WTR/Text+Fields
<SPAN class=Apple-style-span style="WORD-SPACING: 0px; FONT: medium Simsun; TEXT-TRANSFORM. none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-S
收藏
举报
TAG: