browser.element(how,what)
常用元素*button e.g: browser.button(:id,'su').click()
*checkbox
*text_field e.g:browser.text_field(:id,'kw').set('watir-webdriver')
*form
*frame
*div
*image
*link
*radio
*select
*table
*text_area
*file_field
*click
*set
*clear
*select
*double_click
*hover
*right_click
*send_keys
*focus
*flash
*fire_event
**Frames
Frames are fairly easy to deal with in Watir-WebDriver, just use them the same way as any other element.
b.frame(:id => "content_ifr").send_keys "hello world"
实例:
1. browser.a(:id => "foo") == browser.a(:id => "foo")
#=> true
2. browser.a(:id => "foo").attribute_value "href"
#=> "http://watir.com"
3.browser.a(:id => "foo").double_click
4.browser.div(:id => "draggable").drag_and_drop_by 100, -200
5.a = browser.div(:id => "draggable")
b = browser.div(:id => "droppable")
a.drag_and_drop_on b
6.browser.a(:id => "foo").fire_event :click
browser.a(:id => "foo").fire_event "mousemove"
browser.a(:id => "foo").fire_event "onmouseover"
7.browser.div(:id => "draggable").flash
8.browser.a(:id => "foo").hover
9.browser.div(:id => "foo").html
#=> "<a>Click</a>"
10.browser.a(:id => "foo").right_click
11.browser.div(:id => "foo").send_keys "Watir", :return
12.browser.a(:id => "foo").style
#=> "display: block"
browser.a(:id => "foo").style "display"
#=> "block"
13.browser.element(:xpath => "//input[@type='submit']").to_subtype
#=> #<Watir::Button>