Watir API Introduction

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.