About Watir installation articles on the Internet a lot, but really no few, not the error is the installation package is wrong. I started is also the first brother, used nearly one weeks to summarize a complete set of installation theory, sharing a bit to everyone can take a few detours. This article provides full-volume installation package downloads, including: Ruby + Watri Automation Deployment integrated Eclipse full-scale 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 when running under CMD. 2 . When installing these two files, note the CD to the appropriate directory. 3. Ruby Upgrade Package installation command: Ruby SETUP.RB4, watir.gem Install command: Gem install Watir--local
(Watir.gem up to 1.5.4 version only.) )
(Full-scale package): http://download.csdn.net/detail/yiyu1/7542847
Watri Instructions for use:
1. Open the editor
2. Use the. RB for your file extension
' Watir '
7. Verify the results
Watri Common Syntax:
1. Using Watir, you need to add the script (fixed notation)
Require ' Watir '
2. Create a test instance of IE
ie = Watir::ie.new
Or go directly to the page as you create it
ie = Watir::ie.start ("http://javame.cnblogs.com";)
Watir use 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. manipulating Web Page objects
4.1 Hyperlinks
4.1.1 using the Text property to click on hyperlinks
Ie.link (: Text, "Pickaxe"). Click
The corresponding HTML code is:
<a href= "http://pragmaticprogrammer.com/titles/ruby/";>pickaxe</a>
4.1.2 using URL properties to click on hyperlinks
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 the Name property to set the check box
Ie.checkbox (: Name, "Checkme"). Set
4.2.2 Use the Name property to clear the check box
Ie.checkbox (: Name, "Checkme"). Clear
4.2.3 using the name and Value property to set the check box
Ie.checkbox (: Name, "Checkme", "1"). Set
4.2.4 Use the name and value properties to clear the check box
Ie.checkbox (: Name, "Checkme", "1"). Clear
The corresponding HTML code is: <input type = "checkbox" name = "Checkme" value = "1" >
4.3 Radio Box
4.3.1 Use the Name property to set the Radio box Ie.radio (: Name, "ClickMe"). Set
4.3.2 Use the Name property to clear the Radio box Ie.radio (: Name, "ClickMe"). Clear
4.3.3 Use the name and ID property to set the Radio box Ie.radio (: Name, "ClickMe", "1"). Set
4.3.4 Use the name and ID properties to clear the Radio box Ie.radio (: Name, "ClickMe", "1"). Clear
The corresponding HTML code is: <input type = "Radio" name = "ClickMe" id = "1" >
4.4 Drop-down box
4.4.1 using the Name property and value to set the drop-down box
Ie.select_list (: Name, "Selectme"). Select ("Is Fun")
4.4.2 Use the Name property and value to clear the drop-down box
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 entering data in a Web page
4.5.1 using the Text input box property to set the input content
Ie.text_field (: Name, "Typeinme"). Set ("Watir World")
4.5.2 Empty the text input box Ie.text_field (: Name, "Typeinme"). The corresponding HTML code for clear is: <input type = "text" name = "Typeinme" >
4.6 submitting data from a Web page
4.6.1 button
4.6.1.1 by value or Title property click the button Ie.button (: Value, "click Me"). Click
4.6.1.2 by the Name property click the button Ie.button (: Name, "ClickMe"). Click
The corresponding HTML code is: <input type = "button" name = "ClickMe" value = "click Me" >
4.6.2 Form
4.6.2.1 buttons in a form use the value or Caption property
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 the picture button in the form uses that property
Ie.button (: Name, "doit"). click
The corresponding HTML code is: <form action = "Submit" name = "Doitform" method= "POST" ><input type= "image" src = "images/doit.gif" n Ame = "doit" ></form>
4.6.2.3 No button form Watir can submit a form by identifying it by its name, action and method attributes. You can submit a form by using the name, action, and Method properties
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 Frame
Ie.show_frames can print out the number and name of the current page frame Watir allows the framework to be accessed through the Name property, such as Ie.frame ("menu") if you want to access a hyperlink in the menu frame, you can
Ie.frame ("menu"). Link (: Text, "click Menu Item"). Click
4.6.4 Nested frames
Ie.frame ("Frame1"). FRAME (: Name, "Nested_frame")
4.6.5 New Window
Some web apps will pop up a new window or open a new window, and you can use the Attach method to access and control the new window. Accessed 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 assign a new window to your IE variable, preferably a different name for the new window