Tips and Tricks
Running Tests With the Browser Not Visible
Run the tests with a -b option if you don't want the browser to be visible. Example:
You can also hide the browser window without using the -b flag. Example:
$HIDE_IE = true
ie = Watir::IE.new()
Running a Test Concurrently
To run a test concurrently, check out concurrent_search.rb
in the examples
directory for an example.
How do I get the version numbers of Ruby and Watir?
Go to command prompt.
For the Watir version type:
ruby -e 'require "watir"; puts Watir::IE::VERSION'
For the Ruby version type:
How to keep command prompt window open after tests are finished?
Do not run your Watir script by double clicking it. Instead, open command prompt, navigate to folder where script is located and execute the script from there.
Glossary
Instance, an object that has been created for use by a program and is stored in memory.
Message, an action descriptor that can be sent to an object. If the object recognizes the message, it will respond and display related behavior.
Object, something that contains attributes and displays behavior according to what messages have been sent to it.
Ruby, object-oriented scripting language.
Watir, Web Application Testing in Ruby.
Feedback
Questions? Comments? The Watir development team like to hear your comments and suggestions for improvement. Email questions and suggestions to the Watir General
Google group. Please read Support before posting.
Examples
Examples are not included with the gem install. You have to download them separately from examples
folder.
To run the Watir example test:
- Download a file from examples folder, google_search.rb
for example.
- At the command prompt, go to directory where you have downloaded it.
- Type the name of the test at the command prompt, and press Enter to run it:
- Look at the source code of the examples and compare it to the web application that it tests.
- Right click on the Ruby test file and select Edit to view its source code in the SciTE editor.
The End
This is the end of the tutorial. Check out other pages at Watir Wiki. Watir unit tests
are good resource.