Main Content

Some TestWise examples - helping use Ruby code to check your web site operation

Archive - Originally posted on "The Horse's Mouth" - 2012-02-24 22:41:33 - Graham Ellis

How to test your website and browser based applications? In a previous article I covered watir-webdriver which lets you run the Firefox Browser from a Ruby script, passing in instructions as to what to fill into certain fields, and then lets you check with all the power of Ruby the pages that are returned as a result.

TestWise goes a whole lot further. You can download an evaluation version from http://itest2.com/en/testwise. Amongst the feature we used on today's private extension to our Ruby course were:
• Adding a driver to Firefox to record operations to paste into Testwise
• Running a series of stories (tests) to ensure that things work according to a plan
• Using Loops and Conditionals to run multiple tests and vary tests depending on earlier results
• Logging issues arising to the console and to files
• Reading data for tests from external data file sources
• Login and page status control
• Using Page objects to associate behaviours with particular pages / page types

Here's our log for today - to give you something of an idea, and as a reminder for delegates:

Early steps to get going

1. Download
2. Install

Seeing TestWise in action


3. Add driver to Firefox (we did this on the mac by going to the URL ...)
file:///Users/grahamellis/Downloads/TestWise.app/Contents/Resources/thirdparty/Firefox_AddOns/testwise_recorder.xpi

4. Run and record some tests on Firefox



5. Cut and paste into a new test file (at the place it tells you if you use the "create new test" template
N.B. Need to modify open_browser:
  open_browser("http://www.wellho.net/index.html")


5a) Run and see (source [here])

6. Duplicate tests (more stories), changing what they do

6a) Run and see (source [here])

Move onto some more facilities


7. Add in some more stuff:
a) browser.text.include to check return pages
b) if, else condition to do different things based on response
c) before(:each) to set the same start sequence for every test

See source code [here]


8 Add loops of tests, arrays, all sorts of things!

See source code [here]

Page Objects


9. Page objects are a refactoring of your testing into page objects. This is a huge help in code maintainability and reusablity ...

See source code [here]



Logging to file and console, reading instructions from file


10. You want log files, and you want inputs from file ... here's how

See source code [here]
Sample output log file [here]
Sample input file [here]