# Watir cheat sheet

## Setup

    require 'watir'
    include Watir

## Get an Instance of IE

    $ie = Watir::IE.new
    #Navigate somewhere else...
    $ie.goto("http://google.com")

## Get A Control (or item)

    #Text Box or Text Area:
    $t = $ie.text_field(:name, "{{Name}}")
    #Button:
    $b = $ie.button(:name, "{{Name}}")
    #Button, with value of 'Click Here'
    $b = $ie.button(:value, "Click Here")
    #Drop Down List:
    $d = $ie.select_list(:name, "{{Name}}")
    #Check Box:
    $c = $ie.checkbox(:name, "{{name}}")
    #Radio Button:
    $r = $ie.radio(:name, "{{name}}")
    #Form -- by name
    $f = $ie.form(:name, "{{name}}")
    #Form -- by action
    $f = $ie.form(:action, "submit")
    #Link (selected by href attribute)
    $l = $ie.link(:url, "http://google.com")

## Manipulate Said Control

    #Click a button or link
    $b.click
    $l.click
    #Change a text box
    $t.set("Text to set")
    #Set radio button or checkbox
    $c.set
    $r.set
    #Clear pretty much any control
    $t.clear
    $c.clear
    $r.clear
    #Drop Down list: Select the item 'Hey!'
    $d.select("Hey!")
    #Drop Down list: Unselect
    $d.clearSelection
    #submit a form
    $f.submit

## Further Reading

- Watir User Guide
- comments/feedback about this page