Using WET to Run a Group of Watir Scripts

August 6, 2008

So what do I do with a bunch of stand-alone scripts in Watir/Ruby?

First, convert them over to use with WET.
- require “WET”
- include Watir
- take out strange symbols to print out such as <>
- Instead of writing results to a file using a loop and the file.puts command, change it to use reporter().ReportGeneral(”instructions here”)

1. Open up WET and click on the TEST icon

2. Select New

3. Click on the top and rename it (this name is used as the title in your results)
Example: Purchase Transaction Tests

4. Under Transactions, click on First Transaction and rename it.
Example : Purchase with credit
On the right hand side, select “choose” and choose the script file you want to use.

5.Go to the menu, add transaction
Rename this transaction as you did in the previous step, and add the other script file.

6. Save as test.defs

7. Execute script from WET or use the command line.

Set of scripts should run. Go to your scripts/results and find the html results file. It will be named after the title you entered (purchase tests. html)

Note: Grouping tests seem to invoke the IE browser only once, so if you have the script close out the browser at the end it may cause errors. Logging out at the end of a script is good practice.

Also, there is a timeout issue I haven’t quite figured out yet. When grouping a bunch of tests into the Test.defs file and trying to Execute Test from WET, there are RPC timeout errors. This is when its best to use the command line

Previous post: Writing Watir script results to a file using WET

Next post: JIRA I Hear Ya!