4
Creating automated test scripts with Ruby and WATIR thoughtworks.com /insights/blog/creating-automated-test-scripts-ruby-and-watir Actions new, back, forward, send_keys, goto, close, refresh, minimize, maximize, restore $ie.back() $ie.forwards() $ie.send_keys(“{TAB}{TAB}{ENTER}”) $ie.close $ie.goto(“http://www.google.com”) $ie = IE.new() Show Functions showFrames, show_frames, showForms, show_forms, showImages, show_images, showActive, show_active, showLinks, show_links, showAllObjects, show_all_objects, show_tables, buttons, show_spans, show_labels, $ie.show_tables $ie.buttons.each {|m| puts m} Child Objects frame, textField, span, row, selectBox, radio, select_list, text_field, checkBox, button, checkbox, link, cell, form, table $ie.frame(:index, 1) $ie.textField(:name, “q”).set(“Test”) $ie.button(:value, “OK”).click $ie.link(:text, “Happy link”).click $ie.select_list(:name, “Day”).select_value(“today”) Object Lists checkboxes, labels, images, spans, radios, select_lists, text_fields, buttons, tables, links $ie.checkboxes.each {|m| puts m} $ie.radios.each {|m| puts m} $ie.links.each {|m| puts m}

Thoughtworks.com-Creating Automated Test Scripts With Ruby and WATIR(1)

  • Upload
    cbgoud

  • View
    214

  • Download
    1

Embed Size (px)

DESCRIPTION

a

Citation preview

Page 1: Thoughtworks.com-Creating Automated Test Scripts With Ruby and WATIR(1)

Creating automated test scripts with Ruby and WATIRthoughtworks.com /insights/blog/creating-automated-test-scripts-ruby-and-watir

Actions new, back, forward, send_keys, goto, close, refresh, minimize, maximize,restore

$ie.back()

$ie.forwards()

$ie.send_keys(“{TAB}{TAB}{ENTER}”)

$ie.close

$ie.goto(“http://www.google.com”)

$ie = IE.new()

ShowFunctions

showFrames, show_frames, showForms, show_forms, showImages,show_images, showActive, show_active, showLinks, show_links,showAllObjects, show_all_objects, show_tables, buttons, show_spans,show_labels,

$ie.show_tables

$ie.buttons.each {|m| puts m}

ChildObjects

frame, textField, span, row, selectBox, radio, select_list, text_field,

checkBox, button, checkbox, link, cell, form, table

$ie.frame(:index, 1)

$ie.textField(:name, “q”).set(“Test”)

$ie.button(:value, “OK”).click

$ie.link(:text, “Happy link”).click

$ie.select_list(:name, “Day”).select_value(“today”)

ObjectLists

checkboxes, labels, images, spans, radios, select_lists, text_fields,buttons, tables, links

$ie.checkboxes.each {|m| puts m}

$ie.radios.each {|m| puts m}

$ie.links.each {|m| puts m}

Page 2: Thoughtworks.com-Creating Automated Test Scripts With Ruby and WATIR(1)

Verification getText, text, getStatus, status, getHTML, html, pageContainsText,contains_text, title

if ($ie.text.match(“Hallo”) != nil)

puts ‘Passed!’

else

puts “Failed!’

$ie.contains_text(“Google”)

Returns : True

MiscFunctions

getImage, getIE, enable_spinner, set_fast_speed, enable_spinner=, wait,popup, down_load_time, getLink, set_slow_speed, getTablePart, focus, url

TEXT FIELD

Description text name=question id= value= alt= src=

Objects textField, text_field

Discoverytechnique

$ie.show_all_objects

$ie.show_active

$ie.textfields.each { |textfield| puts textfield}

RelevantMethods

value, value=, clear, click, send, set, enabled?, flash, html, append,getContents, focus, verify_contains

Most usedmethods

value, set, append, verify_contains. Sometimes value= when having troublewith popups.

Examples $ie.textField(:name, “q”).value=”Sam”

$ie.textField(:name, “q”).append(“I am”)

$ie.textField(:name, “q”).value

Returns : “Sam I am”

$ie.textField(:name, “q”).getContents

Returns : “Sam I am”

$ie.textField(:name, “q”).set(“Happy”)

$ie.textField(:name, “q”).verify_contains(“app”)

Returns : true

Page 3: Thoughtworks.com-Creating Automated Test Scripts With Ruby and WATIR(1)

BUTTON

Description submit name=btnG id= value=Google Search alt= src=

Objects button

Discoverytechnique

$ie.show_all_objects

$ie.show_active

$ie.buttons.each { |button| puts button }

RelevantMethods

value, display, click, send, enabled?, flash, html, disabled, freeze, focus

Most usedmethods

Click

Examples $ie.button(:name, “btnG”).click

$ie.button(:name, “btnG”).value

Returns : “Google Search”

LINK

Description " name= id= innerText=Business Solutionshref=https://www.google.com/services/"

Objects Link

Discoverytechnique

$ie.show_links

$ie.show_active

$ie.links.each { |link| puts link }

RelevantMethods

value, title, click, link_has_image, enabled?, flash, html, href, src, text, focus,name, innerText, equal?

Most usedmethods

Click

Examples $ie.link(:text, “Business Solutions”).click

$ie.link(:text, “Business Solutions”).enabled?

Returns : true

$ie.link(:text, “Business Solutions”).link_has_image

Returns : false

Page 4: Thoughtworks.com-Creating Automated Test Scripts With Ruby and WATIR(1)