Ruby-based watir automated test Note 2

Source: Internet
Author: User

The supplemental version of ruby-based watir automated test Note 1 adds some special control capture methods. Updating ....

 

Attribute_value

Obtains the properties of the current control.

Value = ie. Link (: Id => 'xxx'). attribute_value ("href ")

 

Rand_select

Randomly select an item in the select list

Ie. select_list (: Name => ''). rand_select

 

Popupwin

Click "OK" in the pop-up window.

Ie. popupwin. Button (: Name => "OK"). Click

 

Sikuli_image

Click image control

Ie. sikuli_image (: Image => "1.png"). Click

Ie. sikuli_image (: Image => "1.png1_2.png"). Click # You can specify multiple images for recognition.

 

Double_click

Double-click event

Ie. sikuli_image (: Image => "1.png"). double_click

 

Right_click

Right-click event

 

Exist?

Determine whether a user element exists

Edit = ie. text_field (: name, "username ")

If edit. exist? ()

# The highlighted

Edit. Flash

Ie. text_field (: name, "password"). Set (PWD)

Ie. Button (: class, "x-login-submit"). Click

End

End

 

Button
Ie. Button (: Name => "",: Id => "",: Index => N,: TYPE => ""). Click
Ie. Button (: Name => "",: Id => "",: Index => N,: TYPE => "" example .doc lick


Input box
Ie. text_field (: Name => ""). Set "variable"
Ie. text_field (: Name => ""). The value of text_field is not in text, but in value!


Drop-down list
Ie. select_list (: Name => ""). Select "drop-down box value"
Ie. select_list (: Name => ""). Select "#1" # indicates the first item.
Ie. select_list (: Name => ""). rand_select
Ie. select_list (: Name => ""). getselecteditems | getallcontents-> return Array


Single region
Ie. Radio (: Id => "",: Name => "",: Index => N). Set (select the current radio)
Ie. Radio (: Id => "",: Name => "",: Index => N). Clear (deselect the current radio)

Ie. Div (: class => "iradio_minimal-bluechecked"). Radios [1]


Check box
IE. check_box (: Id => "",: Name => "",: Index => N ). set (true | false) (true indicates selected, false indicates not selected)
Ie. check_box (: Id => "",: Name => "",: Index => N). Clear (deselect the current checkbox)


Link
Ie. Link (: text => ""). Click/doclick
Ie. Link (: text => ""). href (returns the link pointed to by the current link)
Cell (TD tag, you usually need to first find the upper-layer controls such as table and Div)
Ie. Table (: class => "",: Index => N). Cell (: class => "",: Index => N). Text
Ie. Table (: Index => N). Rows row column. Text (rows and columns start from 1)
Ie. Div (: class => "",: Index => N). Cell (: class => "",: Index => N). Text
Span
Ie. Table (: Id => ""). span (: class => ""). Text


Dialog Box
Ie. popupwin. get_static_text (return the text of the current prompt box)
Ie. popupwin. Button (: Name => "OK"). Click/doclick (doclick is required for the previous button)
Ie. file_dialog (: Index => 1/2). set_file (file_path_download, true) (the pop-up window for saving files)


Image
Ie. Image (: src =>/word3a_nor.gif/). Click/doclick

Back

Back

Ie. Back

 

Forward

Forward

Ie. Forward

Refresh

Refresh page

Ie. Refresh

 

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.