# Scripting Web Tests

with Watir and Ruby

Workbook / Solutions / 2. The Watir Console

## Sample Solution for Lab 2. The Watir Console

Lab 2. The Watir Console

The commands you enter in the Watir Console may be something like this.

    # session start: Sun Aug 12 19:55:33 -0500 2007
    b = Watir::IE.start('http://localhost:3000/store')
    b.link(:href, 'http://localhost:3000/store/add_to_cart/4').flash
    b.link(:href, 'http://localhost:3000/store/add_to_cart/4').click
    b.link(:text, 'Checkout').click
    b.text_field(:id, 'order_name').flash
    b.text_field(:id, 'order_name').set('Steven List')
    b.text_field(:id, 'order_email').flash
    b.text_field(:id, 'order_email').set('doc@gmail.com')
    b.text_field(:id, 'order_address').flash
    b.text_field(:id, 'order_address').set("123 Main St.\nWashington D.C.")
    b.select_list(:id, 'order_pay_type').flash
    b.select_list(:id, 'order_pay_type').select('Check')
    b.button(:name, 'commit').flash
    b.button(:name, 'commit').click
    exit
    # session stop: Sun Aug 12 20:03:33 -0500 2007