Text Box:
<INPUT id = "email" name = "_ fmu. u. _ 0.e" value =" "/>
Method 1: ie. text_field (: id, 'email '). set ("text content ")
Method 2: ie. text_field (: name, 'email '). set ("text content ")
Method 3: ie. text_field (: name, "email"). clear
Drop-down box:
<SELECT name = "cert_no">
<OPTION value = "ID card"> ID card </OPTION>
</SELECT>
Method 1: ie. select_list (: name, "cert_no"). select ("ID card ")
Method 2: ie. select_list (: name, "cert_no"). clearSelection
Hyperlink:
<A href = "http://www.google.cn/"> google </a>
Method 1: ie. link (: text, "google"). click
Method 2: ie. link (: url, "http://www.google.cn/"). click
Check box:
<Input type = "checkbox" name = "checkme" value = "1">
Method 1: ie. checkbox (: name, "checkme"). set
Method 2: ie. checkbox (: name, "checkme"). clear
Method 3: values = ie. checkbox (: name, "checkme"). value
<Input type = "checkbox" name = "checkme" value = "2">
# Process multiple check boxes with the same name
Method 1: IE. checkbox (: name, "checkme", "2"). Set
Method 2: IE. checkbox (: name, "checkme", "2"). Clear
Single region:
<Input type = "radio" name = "clickme" id = "1">
Method 1: IE. Radio (: name, "clickme"). Set
Method 2: IE. Radio (: name, "clickme"). Clear
General buttons:
<Input type = "button" name = "clickme" value = "Click me">
Method 1: IE. Button (: value, "click me"). Click
Method 2: IE. Button (: name, "clickme"). Click
Submit button:
<Form action = "Submit" name = "submitform" method = "Post">
<Input type = "Submit" value = "Submit"> </input>
</Form>
Method: IE. Button (: value. "Submit"). Click
Image button:
<Form action = "Submit" name = "doitform" method = "Post">
<Input type = "image" src = "images/doit.gif" name = "doit">
</Form>
Method: IE. Button (: name, "doit"). Click
No buttons in Form:
<Form action = "login" name = "loginform" method = "get">
<Input name = "username" type = "text"> </input>
</Form>
Method 1: IE. Form (: name, "loginform"). Submit
Method 2: IE. Form (: Action, "login"). Submit
Obtain the implicit object value:
<Input type = hidden value = "your email" name = "field1">
Method: Values = ie. Hidden (: name, 'field1'). Value
Get window objects:
Method 1: ie2 = Watir: IE. attach (: url, 'HTTP: // www.google.cn/') # obtain from URL
Method 2: ie3 = Watir: IE. attach (: title, 'Google ') # obtain it based on the window title
Method 3: ie4 = watir: IE. Attach (: title,/google.cn/) # obtain the regular expression matching
URL encoding:
Require 'cgi'
String = "URL encoding"
String = CGI: escape (string)
Puts string # Conversion Result: URL % B1 % E0 % C2 % EB
URL Decoding:
Require 'cgi'
String = "url % BD % E2 % C2 % Eb"
String = CGI: Unescape (string)
Puts string # Conversion Result: URL Decoding
From: http://www.cnblogs.com/sky_online/archive/2008/08/12/1265646.html