WatirYesRubyOpen SourceWebCompared with the large commercial tools, the automated testing framework is small, flexible, and provides sufficient functions. Recently, I took the time to try it out. I feel pretty good. I plan to use it in the company for further promotion.
BecauseWatirUser Manual and examples on the websiteCodeAndFAQAll of them are well maintained, so I will not repeat the existing items. Here I will briefly introduce them. If you are interested, you can study them together.
1.Script example
First, I will drop a script to show you how to use it.WatirHow convenient it is to write scripts. The example below is:WatirBuilt-in Test SectionGoogleBut I only keep the most important part to make it look more concise:
Require 'watir'# The watir Controller
# Open the IE browser
Ie = watir: IE. New
# Step 1: Go to the test site: http://www.google.com
Ie. Goto (http://www.google.com)
# Step 2: Enter 'pickaxe' in the search text field
Ie. text_field (: name, "Q"). Set ("Pickaxe ")# Q is the name of the search field
# Step 3: Click the 'Google search' button
Ie. Button (: name, "btng"). Click# "Btng" is the name of the Search button
# Actual result: Check that the 'programming Ruby 'link appears on the results page
If Ie. contains_text ("programming ruby ")
Puts "test passed. Found the test string: 'Programming Ruby '. Actual results match expected results ."
Else
Puts "test failed! Cocould not find: 'Programming Ruby '"
End
# End of test: Google Search
what to do with this script is to open Google Google enter" pickaxe ", and then press " goo GLE Search "button, then verify that the search result page contains " programming ruby " and use puts the function prints different information on the screen. In the script, " # " is the content of the comment. Simple? To be honest, it is simpler and simpler than the scripts recorded by commercial tools.
2.Required Environment
RUBY: because it is implemented using ruby , the script is also ruby , therefore, you must install ruby on the local machine. You can click here download. According to the document, it is best to select Ruby 1.8.2-14 or a later version, I installed Ruby 1.8.2-15 stable release .
watir: you can click here download, I downloaded watir 1.4 , is a . zip file. decompress the file and run install. RB , for more information about installation and configuration, see watir User Manual . Don't be afraid. Although it is in English, it is very simple.
Windows 2000OrXP + Internet Explorer 5.5Later versions:AccordingWatirThe description on the website. This is the environment they currently support.
3.Background
Because, after all, you still need to write code, so development experience is necessary, and development experience in any language is acceptable-although Ruby It is an object-oriented scripting language, but you can ignore it for the moment (do not be intimidated by object-oriented, scripting language and other words). If you have written VBScript Or other code Watir It is very simple. However, you need to know Web Development, such Html The basic syntax Web PageSource codeTo determine Web Object Recognition Methods-of course, they can also be implemented using other tools, such Mozilla Firefox " Dom Viewer Mozilla Firefox Find the tool in the menu. For more information, see Mozilla Firefox Help ).
In addition, basic knowledge about testing and automated testing is required.
4.Script generation
Don't think about the recording function,WatirThis feature is not provided. If you are not using recording, choose another one. However, as far as I use it,WatirComparedQtpOrRationalTool recording is also convenient and fast.
5.Object identification, operations, and automatic verification
watir provides a variety of common Web supports object recognition and operations, such as hyperlinks click, checkboxes select and clear, radio buttons selection and clearing, selection of drop-down boxes and list boxes, text box input, click of various buttons, and frame watir User Manual .
6.Other features
If you are familiarRuby, Combined with other tools, you canWatirThe framework expands many features. For example, reading external files or databases, modular development, reusable function libraries, data drivers, keyword drivers, Version Control of scripts, and management of test results.
7.Related Links
WatirHome page:Http://wtr.rubyforge.org/
RubyChinese manual:Http://www.ruby-cn.org/doc.html
RubyHome page:Http://ruby-lang.org/en/
As mentioned above, Watir User Manual, FAQ And other aspects of the maintenance is very good, if the complete read Watir On the home page Sample Test And User's Guide Basically, you can use Watir Start testing Web Application. If you are interested in further research, refer Technical Doc You can also read Watir Examples. Of course, you can leave a message or Email I will discuss it with you.