Ruby + watir integrates Eclipse automated installation and deployment and syntax, with the full installation package

Source: Internet
Author: User

There are a lot of articles about Watir installation on the Internet, but few of them are actually reliable. Either an error is reported or the installation package is incorrect. I started out as a beginner. It took nearly a week to summarize a complete set of installation theories, so that I could share some detours with you. This article provides full installation package downloads, including: ruby + watri automated deployment integrated Eclipse full installation package (including: watir-1.5.4, ruby186-26, WatirRecorder_Setup_lite, dltk-core-ruby, dotnetfx, rubygems-1.3.7, installation instructions.

Installation instructions:
1. Install ruby's gem upgrade package and watir. gem and run it in cmd. 2. When installing these two files, pay attention to cd to the corresponding directory. 3. ruby gem upgrade package installation command: ruby setup. rb4, watir. gem installation command: gem install watir -- local
(Watir. gem can only be installed in version 1.5.4 .)

(Full package): http://download.csdn.net/detail/yiyu1/7542847

Watri instructions:

1. Open the editor
2. Use. rb as your file extension
3. Write "require 'watir'" in the first sentence of the test file to ensure that the watir tool is accessible.
4. Open the browser and go to the application to be tested
5. interact with it and design your testcase
6. Use the Watir method in the test script
7. Verification results

Common watri Syntax:

1. To use Watir, you must add it to the script (fixed Statement)
Require 'watir'
2. Create an IE test instance
Ie = Watir: IE. new
Or directly go to the page while creating
Ie = Watir: IE. start ("http://javame.cnblogs.com ";)
Watir uses the start method to create a browser instance at the same time and go to a page.

3.Page navigation
Ie. goto ("http://javame.cnblogs.com ";)

4.Manipulate Web page objects
4.1 hyperlink
4.1.1 click a hyperlink using the Text attribute
Ie. link (: text, "Pickaxe"). click
The corresponding HTML code is:
<A href = "http://pragmaticprogrammer.com/titles/ruby/";> Pickaxe </a>

4.1.2 click a hyperlink using URL attributes
Ie. link (: url, "http://pragmaticprogrammer.com/titles/ruby/";). click
The corresponding HTML code is: <a href = "http://pragmaticprogrammer.com/titles/ruby/";> Test Site </a>

4.2 check box
4.2.1 use name attribute setting check box
Ie. checkbox (: name, "checkme"). set
4.2.2 clear the check box using the name attribute
Ie. checkbox (: name, "checkme"). clear
4.2.3 use name and value attributes to set check boxes
Ie. checkbox (: name, "checkme", "1"). set
4.2.4 clear the check box using the name and value Attributes
Ie. checkbox (: name, "checkme", "1"). clear
The corresponding HTML code is: <input type = "checkbox" name = "checkme" value = "1">

4.3 single region
4.3.1 use the name attribute to set a single ie. radio (: name, "clickme"). set
4.3.2 clear singleie. radio (: name, "clickme"). clear using the name attribute
4.3.3 use the name and id attributes to set singleie. radio (: name, "clickme", "1"). set
4.3.4 clear a ticket using the name and id attributes. radio (: name, "clickme", "1"). clear
The corresponding HTML code is: <input type = "radio" name = "clickme" id = "1">

4.4 drop-down list
4.4.1 use the name attribute and value to set the drop-down list
Ie. select_list (: name, "selectme"). select ("is fun ")
4.4.2 clear the drop-down box using the name attribute and Value
Ie. select_list (: name, "selectme"). clearSelection
The corresponding HTML code is: <select name = "selectme"> <option name = 1> <option name = 2> Web Testing <option name = 3> in Ruby <option name = 4> is fun </ select>

4.5 enter data on the Web page
4.5.1 set the input content using the attributes in the text input box
Ie. text_field (: name, "typeinme"). set ("Watir World ")
4.5.2 clear the text input box ie. text_field (: name, "typeinme"). The HTML code corresponding to clear is: <input type = "text" name = "typeinme">

4.6 submit data from the web page
4.6.1 button
4.6.1.1 Click ie. button (: value, "click Me") by value or title attribute. Click
4.6.1.2 click ie. button (: name, "clickme") through the name attribute. click
The corresponding HTML code is: <input type = "button" name = "clickme" value = "Click Me">

4.6.2 form
4.6.2.1 use value or title attribute for buttons in the form
Ie. button (: value, "Submit"). click
The corresponding HTML code is: <form action = "submit" name = "submitform" method = "post"> <input type = "submit" value = "Submit"> </input> </form>

4.6.2.2 attributes used by the image button in the form
Ie. button (: name, "doit"). click
The corresponding HTML code is: <form action = "submit" name = "doitform" method = "post"> <input type = "image" src = "images/doit.gif" name = "doit"> </ form>

4.6.2.3 form without buttons Watir can submit a form by identifying it by its name, action and method attributes. You can submit a form using the name, action, and method attributes.
Ie. form (: name, "loginform"). submit ie. form (: action, "login"). submit
The corresponding HTML code is: <form action = "login" name = "loginform" method = "get"> <input name = "username" type = "text"> </input> </form>

4.6.3 framework
Ie. show_frames can print the number and name of the current page framework. Watir allows you to access the framework by using the name attribute, such as ie. frame ("menu") to access a hyperlink in the menu frame, you can
Ie. frame ("menu"). link (: text, "Click Menu Item"). click
4.6.4 nested framework
Ie. frame ("frame1"). frame (: name, "nested_frame ")
4.6.5 new window
Some Web applications will pop up a new window or open a new window. You can use the attach method to access and control the new window. Access by marking the URL or title of the new window.
Ie2 = Watir: IE. attach (: url, 'HTTP: // mytestsite ')
Ie3 = Watir: IE. attach (: title, 'test New window') can also use regular expressions.
Ie4 = Watir: IE. attach (: title,/Test New /)
Note: Do not allocate the new window to your ie variable. It is best to give the new window a different name.

 

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.