class PageObject::Platforms::WatirWebDriver::PageObject

Watir implementation of the page object platform driver. You should not use the class directly. Instead you should include the PageObject module in your page object and use the methods dynamically added from the PageObject::Accessors module.

Attributes

browser[R]

Public Class Methods

new(browser) click to toggle source
# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 17
def initialize(browser)
  @browser = browser
end

Public Instance Methods

alert(frame=nil) { || ... } click to toggle source

platform method to handle an alert popup See PageObject#alert

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 72
def alert(frame=nil, &block)
  switch_to_frame(frame)
  yield
  value = nil
  if @browser.alert.exists?
    value = @browser.alert.text
    @browser.alert.ok
  end
  switch_to_default_content(frame)
  value
end
area_for(identifier) click to toggle source

platform method to retrieve an area element

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 859
def area_for(identifier)
  find_watir_element("area(identifier)", Elements::Area, identifier, 'area')
end
areas_for(identifier) click to toggle source

platform method to retrieve an array of area elements

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 866
def areas_for(identifier)
  find_watir_elements("areas(identifier)", Elements::Area, identifier, 'area')
end
attach_to_window(identifier, &block) click to toggle source

platform method to handle attaching to a running window See PageObject#attach_to_window

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 126
def attach_to_window(identifier, &block)
  win_id = {identifier.keys.first => /#{Regexp.escape(identifier.values.first)}/}
  @browser.window(win_id).use &block
end
audio_for(identifier) click to toggle source

platform method to retrieve an audio element

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 887
def audio_for(identifier)
  find_watir_element("audio(identifier)", Elements::Audio, identifier, 'audio')
end
audios_for(identifier) click to toggle source

platform method to retrieve an array of audio elements

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 894
def audios_for(identifier)
  find_watir_elements("audios(identifier)", Elements::Audio, identifier, 'audio')
end
back() click to toggle source

platform method to go back to the previous page See PageObject#back

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 170
def back
  @browser.back
end
button_for(identifier) click to toggle source

platform method to retrieve a button element See PageObject::Accessors#button

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 473
def button_for(identifier)
  call = call_for_watir_element(identifier, "button(identifier)")
  find_watir_element(call, Elements::Button, identifier)
end
buttons_for(identifier) click to toggle source

platform method to retrieve an array of button elements

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 481
def buttons_for(identifier)
  call = call_for_watir_elements(identifier, "buttons(identifier)")
  find_watir_elements(call, Elements::Button, identifier)
end
canvas_for(identifier) click to toggle source

platform method to retrieve a canvas element

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 873
def canvas_for(identifier)
  find_watir_element("canvas(identifier)", Elements::Canvas, identifier, 'canvas')
end
canvass_for(identifier) click to toggle source

platform method to retrieve an array of canvas elements

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 880
def canvass_for(identifier)
  find_watir_elements("canvases(identifier)", Elements::Canvas, identifier, 'canvas')
end
cell_for(identifier) click to toggle source

platform method to retrieve a table cell element See PageObject::Accessors#cell

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 522
def cell_for(identifier)
  find_watir_element("td(identifier)", Elements::TableCell, identifier, 'td')
end
cell_text_for(identifier) click to toggle source

platform method to retrieve the text from a table cell See PageObject::Accessors#cell

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 513
def cell_text_for(identifier)
  process_watir_call("td(identifier).text", Elements::TableCell, identifier,
                     nil, 'td')
end
cells_for(identifier) click to toggle source

platform method to retrieve an array of table cell elements

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 529
def cells_for(identifier)
  find_watir_elements("tds(identifier)", Elements::TableCell, identifier, 'td')
end
check_checkbox(identifier) click to toggle source

platform method to check a checkbox See PageObject::Accessors#checkbox

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 348
def check_checkbox(identifier)
  process_watir_call("checkbox(identifier).set", Elements::CheckBox, identifier)
end
checkbox_checked?(identifier) click to toggle source

platform method to determine if a checkbox is checked See PageObject::Accessors#checkbox

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 364
def checkbox_checked?(identifier)
  process_watir_call("checkbox(identifier).set?", Elements::CheckBox, identifier)
end
checkbox_for(identifier) click to toggle source

platform method to return a PageObject::Elements::CheckBox element See PageObject::Accessors#checkbox

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 372
def checkbox_for(identifier)
  find_watir_element("checkbox(identifier)", Elements::CheckBox, identifier)
end
checkboxs_for(identifier) click to toggle source

platform method to retrieve an array of checkbox elements

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 379
def checkboxs_for(identifier)
  find_watir_elements("checkboxes(identifier)", Elements::CheckBox, identifier)
end
choose_label(identifier) click to toggle source

platform method to return a PageObject::Element::Label element See PageObject::Accessors#label

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 813
def choose_label(identifier)
  process_watir_call("label(identifier).click", Elements::Label, identifier, 'label')
end
clear_cookies() click to toggle source

platform method to clear the cookies from the browser See PageObject#clear_cookies

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 186
def clear_cookies
  @browser.cookies.clear
end
click_area_for(identifier) click to toggle source

platform method to click on an area

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 852
def click_area_for(identifier)
  process_watir_call("area(identifier).click", Elements::Area, identifier, nil, 'area')
end
click_button_for(identifier) click to toggle source

platform method to click a button See PageObject::Accessors#button

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 464
def click_button_for(identifier)
  call = call_for_watir_element(identifier, "button(identifier)")
  process_watir_call("#{call}.click", Elements::Button, identifier)
end
confirm(response, frame=nil) { || ... } click to toggle source

platform method to handle a confirm popup See PageObject#confirm

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 88
def confirm(response, frame=nil, &block)
  switch_to_frame(frame)
  yield
  value = nil
  if @browser.alert.exists?
    value = @browser.alert.text
    response ? @browser.alert.ok : @browser.alert.close
  end
  switch_to_default_content(frame)
  value
end
current_url() click to toggle source

platform method to get the current url See PageObject#current_url

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 33
def current_url
  @browser.url
end
div_for(identifier) click to toggle source

platform method to return a PageObject::Elements::Div element See PageObject::Accessors#div

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 426
def div_for(identifier)
  find_watir_element("div(identifier)", Elements::Div, identifier, 'div')
end
div_text_for(identifier) click to toggle source

platform method to return the text for a div See PageObject::Accessors#div

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 418
def div_text_for(identifier)
  process_watir_call("div(identifier).text", Elements::Div, identifier, nil, 'div')
end
divs_for(identifier) click to toggle source

platform method to retrieve an array of div elements

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 433
def divs_for(identifier)
  find_watir_elements("divs(identifier)", Elements::Div, identifier, 'div')
end
element_for(tag, identifier) click to toggle source

platform method to return a PageObject::Elements::Element element See PageObject::Accessors#element

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 916
def element_for(tag, identifier)
  find_watir_element("#{tag.to_s}(identifier)", Elements::Element, identifier, tag.to_s)
end
element_with_focus() click to toggle source
# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 131
def element_with_focus
  element = browser.execute_script("return document.activeElement")
  type = element.type.to_sym if element.tag_name.to_sym == :input
  cls = ::PageObject::Elements.element_class_for(element.tag_name, type)
  cls.new(element, :platform => :watir_webdriver)    
end
elements_for(tag, identifier) click to toggle source

platform method to return an array of PageObject::Elements::Element elements See PageObject::Accessors#element

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 924
def elements_for(tag, identifier)
  find_watir_elements("#{tag.to_s}s(identifier)", Elements::Element, identifier, tag.to_s)
end
execute_script(script, *args) click to toggle source

platform method to execute javascript on the browser See PageObject#execute_script

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 118
def execute_script(script, *args)
  @browser.execute_script(script, *args)
end
file_field_for(identifier) click to toggle source

platform method to retrieve a file_field element See PageObject::Accessors#file_field

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 838
def file_field_for(identifier)
  find_watir_element("file_field(identifier)", Elements::FileField, identifier)
end
file_field_value_set(identifier, value) click to toggle source

platform method to set the file on a file_field element See PageObject::Accessors#file_field

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 829
def file_field_value_set(identifier, value)
  process_watir_call("file_field(identifier).set(value)", Elements::FileField,
                     identifier, value)
end
file_fields_for(identifier) click to toggle source

platform method to retrieve an array of file field elements

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 845
def file_fields_for(identifier)
  find_watir_elements("file_fields(identifier)", Elements::FileField, identifier)
end
form_for(identifier) click to toggle source

platform method to retrieve a form element See PageObject::Accessors#form

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 552
def form_for(identifier)
  find_watir_element("form(identifier)", Elements::Form, identifier)
end
forms_for(identifier) click to toggle source

platform method to retrieve an array of forms

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 559
def forms_for(identifier)
  find_watir_elements("forms(identifier)", Elements::Form, identifier)
end
forward() click to toggle source

platform method to go forward to the next page See PageObject#forward

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 178
def forward
  @browser.forward
end
h1_for(identifier) click to toggle source

platform method to retrieve the h1 element See PageObject::Accessors#h1

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 644
def h1_for(identifier)
  find_watir_element("h1(identifier)", Elements::Heading, identifier, 'h1')
end
h1_text_for(identifier) click to toggle source

platform method to retrieve the text for a h1 See PageObject::Accessors#h1

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 636
def h1_text_for(identifier)
  process_watir_call("h1(identifier).text", Elements::Heading, identifier, nil, 'h1')
end
h1s_for(identifier) click to toggle source

platform method to retrieve an array of h1s

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 651
def h1s_for(identifier)
  find_watir_elements("h1s(identifier)", Elements::Heading, identifier, 'h1')
end
h2_for(identifier) click to toggle source

platform method to retrieve the h2 element See PageObject::Accessors#h2

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 667
def h2_for(identifier)
  find_watir_element("h2(identifier)", Elements::Heading, identifier, 'h2')
end
h2_text_for(identifier) click to toggle source

platform method to retrieve the text for a h2 See PageObject::Accessors#h2

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 659
def h2_text_for(identifier)
  process_watir_call("h2(identifier).text", Elements::Heading, identifier, nil, 'h2')
end
h2s_for(identifier) click to toggle source

platform method to retrieve an array of h2s

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 674
def h2s_for(identifier)
  find_watir_elements("h2s(identifier)", Elements::Heading, identifier, 'h2')
end
h3_for(identifier) click to toggle source

platform method to retrieve the h3 element See PageObject::Accessors#h3

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 690
def h3_for(identifier)
  find_watir_element("h3(identifier)", Elements::Heading, identifier, 'h3')
end
h3_text_for(identifier) click to toggle source

platform method to retrieve the text for a h3 See PageObject::Accessors#h3

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 682
def h3_text_for(identifier)
  process_watir_call("h3(identifier).text", Elements::Heading, identifier, nil, 'h3')
end
h3s_for(identifier) click to toggle source

platform method to retrieve an array of h3s

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 697
def h3s_for(identifier)
  find_watir_elements("h3s(identifier)", Elements::Heading, identifier, 'h3')
end
h4_for(identifier) click to toggle source

platform method to retrieve the h4 element See PageObject::Accessors#h4

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 713
def h4_for(identifier)
  find_watir_element("h4(identifier)", Elements::Heading, identifier, 'h4')
end
h4_text_for(identifier) click to toggle source

platform method to retrieve the text for a h4 See PageObject::Accessors#h4

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 705
def h4_text_for(identifier)
  process_watir_call("h4(identifier).text", Elements::Heading, identifier, nil, 'h4')
end
h4s_for(identifier) click to toggle source

platform method to retrieve an array of h4s

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 720
def h4s_for(identifier)
  find_watir_elements("h4s(identifier)", Elements::Heading, identifier, 'h4')
end
h5_for(identifier) click to toggle source

platform method to retrieve the h5 element See PageObject::Accessors#h5

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 736
def h5_for(identifier)
  find_watir_element("h5(identifier)", Elements::Heading, identifier, 'h5')
end
h5_text_for(identifier) click to toggle source

platform method to retrieve the text for a h5 See PageObject::Accessors#h5

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 728
def h5_text_for(identifier)
  process_watir_call("h5(identifier).text", Elements::Heading, identifier, nil, 'h5')
end
h5s_for(identifier) click to toggle source

platform method to retrieve an array of h5s

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 743
def h5s_for(identifier)
  find_watir_elements("h5s(identifier)", Elements::Heading, identifier, 'h5')
end
h6_for(identifier) click to toggle source

platform method to retrieve the h6 element See PageObject::Accessors#h6

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 759
def h6_for(identifier)
  find_watir_element("h6(identifier)", Elements::Heading, identifier, 'h6')
end
h6_text_for(identifier) click to toggle source

platform method to retrieve the text for a h6 See PageObject::Accessors#h6

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 751
def h6_text_for(identifier)
  process_watir_call("h6(identifier).text", Elements::Heading, identifier, nil, 'h6')
end
h6s_for(identifier) click to toggle source

platform method to retrieve an array of h6s

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 766
def h6s_for(identifier)
  find_watir_elements("h6s(identifier)", Elements::Heading, identifier, 'h6')
end
hidden_field_for(identifier) click to toggle source

platform method to retrieve a hidden field element See PageObject::Accessors#hidden_field

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 242
def hidden_field_for(identifier)
  find_watir_element("hidden(identifier)", Elements::HiddenField, identifier)
end
hidden_field_value_for(identifier) click to toggle source

platform method to get the value stored in a hidden field See PageObject::Accessors#hidden_field

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 234
def hidden_field_value_for(identifier)
  process_watir_call("hidden(identifier).value", Elements::HiddenField, identifier)
end
hidden_fields_for(identifier) click to toggle source

platform method to retrieve an array of hidden field elements

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 249
def hidden_fields_for(identifier)
  find_watir_elements("hiddens(identifier)", Elements::HiddenField, identifier)
end
html() click to toggle source

platform method to retrieve the html for the current page See PageObject#html

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 49
def html
  @browser.html
end
image_for(identifier) click to toggle source

platform method to retrieve an image element See PageObject::Accessors#image

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 537
def image_for(identifier)
  find_watir_element("image(identifier)", Elements::Image, identifier)
end
images_for(identifier) click to toggle source

platform method to retrieve an array of image elements

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 544
def images_for(identifier)
  find_watir_elements("images(identifier)", Elements::Image, identifier)
end
in_frame(identifier, frame=nil, &block) click to toggle source

platform method to switch to a frame and execute a block See PageObject#in_frame

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 142
def in_frame(identifier, frame=nil, &block)
  frame = [] if frame.nil?
  frame << {frame: identifier}
  block.call(frame)
end
in_iframe(identifier, frame=nil, &block) click to toggle source

platform method to switch to an iframe and execute a block See PageObject#in_frame

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 152
def in_iframe(identifier, frame=nil, &block)
  frame = [] if frame.nil?
  frame << {iframe: identifier}
  block.call(frame)
end
label_for(identifier) click to toggle source

platform method to return a PageObject::Elements::Label element See PageObject::Accessors#label

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 805
def label_for(identifier)
  find_watir_element("label(identifier)", Elements::Label, identifier, 'label')
end
label_text_for(identifier) click to toggle source

platform method to return the text for a label See PageObject::Accessors#label

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 797
def label_text_for(identifier)
  process_watir_call("label(identifier).text", Elements::Label, identifier, nil, 'label')
end
labels_for(identifier) click to toggle source

platform method to retrieve an array of label elements

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 821
def labels_for(identifier)
  find_watir_elements("labels(identifier)", Elements::Label, identifier, 'label')
end
list_item_for(identifier) click to toggle source

platform method to retrieve a list item element See PageObject::Accessors#list_item

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 575
def list_item_for(identifier)
  find_watir_element("li(identifier)", Elements::ListItem, identifier, 'li')
end
list_item_text_for(identifier) click to toggle source

platform method to retrieve the text from a list item See PageObject::Accessors#list_item

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 567
def list_item_text_for(identifier)
  process_watir_call("li(identifier).text", Elements::ListItem, identifier, nil, 'li')
end
list_items_for(identifier) click to toggle source

platform method to retrieve an array of list items

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 582
def list_items_for(identifier)
  find_watir_elements("lis(identifier)", Elements::ListItem, identifier, 'li')
end
navigate_to(url) click to toggle source

platform method to navigate to a provided url See PageObject#navigate_to

ordered_list_for(identifier) click to toggle source

platform method to retrieve an ordered list element See PageObject::Accessors#ordered_list

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 621
def ordered_list_for(identifier)
  find_watir_element("ol(identifier)", Elements::OrderedList, identifier, 'ol')
end
ordered_list_text_for(identifier) click to toggle source

platform method to retrieve the text from an ordered list See PageObject::Accessors#ordered_list

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 613
def ordered_list_text_for(identifier)
  process_watir_call("ol(identifier).text", Elements::OrderedList, identifier, nil, 'ol')
end
ordered_lists_for(identifier) click to toggle source

platform method to retrieve an array of ordered lists

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 628
def ordered_lists_for(identifier)
  find_watir_elements("ols(identifier)", Elements::OrderedList, identifier, 'ol')
end
paragraph_for(identifier) click to toggle source

platform method to retrieve the paragraph element See PageObject::Accessors#paragraph

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 782
def paragraph_for(identifier)
  find_watir_element("p(identifier)", Elements::Paragraph, identifier, 'p')
end
paragraph_text_for(identifier) click to toggle source

platform method to retrieve the text for a paragraph See PageObject::Accessors#paragraph

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 774
def paragraph_text_for(identifier)
  process_watir_call("p(identifier).text", Elements::Paragraph, identifier, nil, 'p')
end
paragraphs_for(identifier) click to toggle source

platform method to retrieve an array of paragraph elements

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 789
def paragraphs_for(identifier)
  find_watir_elements("ps(identifier)", Elements::Paragraph, identifier, 'p')
end
prompt(answer, frame=nil) { || ... } click to toggle source

platform method to handle a prompt popup See PageObject#prompt

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 104
def prompt(answer, frame=nil, &block)
  switch_to_frame(frame)
  @browser.wd.execute_script "window.prompt = function(text, value) { window.__lastWatirPrompt = { message: text, default_value: value }; return #{answer}; }"
  yield
  result = @browser.wd.execute_script "return window.__lastWatirPrompt"
  switch_to_default_content(frame)
  result && result.dup.each_key { |k| result[k.to_sym] = result.delete(k) }
  result
end
radio_button_for(identifier) click to toggle source

platform method to return a PageObject::Eements::RadioButton element See PageObject::Accessors#radio_button

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 403
def radio_button_for(identifier)
  find_watir_element("radio(identifier)", Elements::RadioButton, identifier)
end
radio_buttons_for(identifier) click to toggle source

platform method to retrieve an array of radio button elements

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 410
def radio_buttons_for(identifier)
  find_watir_elements("radios(identifier)", Elements::RadioButton, identifier)
end
radio_selected?(identifier) click to toggle source

platform method to determine if a radio button is selected See PageObject::Accessors#radio_button

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 395
def radio_selected?(identifier)
  process_watir_call("radio(identifier).set?", Elements::RadioButton, identifier)
end
refresh() click to toggle source

platform method to refresh the page See PageObject#refresh

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 162
def refresh
  @browser.refresh
end
save_screenshot(file_name) click to toggle source

platform method to save the current screenshot to a file See PageObject#save_screenshot

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 194
def save_screenshot(file_name)
  @browser.wd.save_screenshot(file_name)
end
select_list_for(identifier) click to toggle source

platform method to return the select list element See PageObject::Accessors#select_list

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 307
def select_list_for(identifier)
  find_watir_element("select_list(identifier)", Elements::SelectList, identifier)
end
select_list_value_for(identifier) click to toggle source

platform method to get the currently selected value from a select list See PageObject::Accessors#select_list

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 289
def select_list_value_for(identifier)
  process_watir_call("select_list(identifier).options.find {|o| o.selected?}.text",
                     Elements::SelectList, identifier)
end
select_list_value_set(identifier, value) click to toggle source

platform method to select a value from a select list See PageObject::Accessors#select_list

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 298
def select_list_value_set(identifier, value)
  process_watir_call("select_list(identifier).select(value)", Elements::SelectList,
                     identifier, value)
end
select_lists_for(identifier) click to toggle source

platform method to retrieve an array of select_list elements

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 314
def select_lists_for(identifier)
  find_watir_elements("select_lists(identifier)", Elements::SelectList, identifier)
end
select_radio(identifier) click to toggle source

platform method to select a radio button See PageObject::Accessors#radio_button

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 387
def select_radio(identifier)
  process_watir_call("radio(identifier).set", Elements::RadioButton, identifier)
end
span_for(identifier) click to toggle source

platform method to return a PageObject::Elements::Span element See PageObject::Accessors#span

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 449
def span_for(identifier)
  find_watir_element("span(identifier)", Elements::Span, identifier, 'span')
end
span_text_for(identifier) click to toggle source

platform method to return the text for a span See PageObject::Accessors#span

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 441
def span_text_for(identifier)
  process_watir_call("span(identifier).text", Elements::Span, identifier, nil, 'span')
end
spans_for(identifier) click to toggle source

platform method to retrieve an array of span elements

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 456
def spans_for(identifier)
  find_watir_elements("spans(identifier)", Elements::Span, identifier, 'span')
end
svg_for(identifier) click to toggle source

platform method to return a svg element

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 931
def svg_for(identifier)
  find_watir_element("element(identifier)", Elements::Element, identifier)
end
svgs_for(identifier) click to toggle source

platform method to return an array of svg elements

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 938
def svgs_for(identifier)
  find_watir_elements("element(identifier)", Elements::Element, identifier)
end
table_for(identifier) click to toggle source

platform method to retrieve a table element See PageObject::Accessors#table

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 498
def table_for(identifier)
  find_watir_element("table(identifier)", Elements::Table, identifier, 'table')
end
table_text_for(identifier) click to toggle source

platform method to return the text for a table See PageObject::Accessors#table

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 490
def table_text_for(identifier)
  process_watir_call("table(identifier).text", Elements::Table, identifier, nil, 'table')
end
tables_for(identifier) click to toggle source

platform method to retrieve an array of table elements

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 505
def tables_for(identifier)
  find_watir_elements("tables(identifier)", Elements::Table, identifier, 'table')
end
text() click to toggle source

platform method to retrieve the text from the current page See PageObject#text

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 41
def text
  @browser.text
end
text_area_for(identifier) click to toggle source

platform method to get the text area element See PageObject::Accessors#text_area

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 274
def text_area_for(identifier)
  find_watir_element("textarea(identifier)", Elements::TextArea, identifier)
end
text_area_value_for(identifier) click to toggle source

platform method to get the text from a textarea See PageObject::Accessors#text_area

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 266
def text_area_value_for(identifier)
  process_watir_call("textarea(identifier).value", Elements::TextArea, identifier)
end
text_area_value_set(identifier, value) click to toggle source

platform method to set text in a textarea See PageObject::Accessors#text_area

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 257
def text_area_value_set(identifier, value)
  process_watir_call("textarea(identifier).set(value)", Elements::TextArea,
                     identifier, value)
end
text_areas_for(identifier) click to toggle source

platform method to retrieve an array of textarea elements

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 281
def text_areas_for(identifier)
  find_watir_elements("textareas(identifier)", Elements::TextArea, identifier)
end
text_field_for(identifier) click to toggle source

platform method to retrieve a text field element See PageObject::Accessors#text_field

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 218
def text_field_for(identifier)
  find_watir_element("text_field(identifier)", Elements::TextField, identifier)
end
text_field_value_for(identifier) click to toggle source

platform method to get the value stored in a text field See PageObject::Accessors#text_field

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 202
def text_field_value_for(identifier)
  process_watir_call("text_field(identifier).value", Elements::TextField, identifier)
end
text_field_value_set(identifier, value) click to toggle source

platform method to set the value for a text field See PageObject::Accessors#text_field

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 210
def text_field_value_set(identifier, value)
  process_watir_call("text_field(identifier).set(value)", Elements::TextField, identifier, value)
end
text_fields_for(identifier) click to toggle source

platform method to retrieve an array of text field elements

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 225
def text_fields_for(identifier)
  elements = find_watir_elements("text_fields(identifier)", Elements::TextField, identifier)
  elements.select {|e| e.element.tag_name == 'input'}
end
title() click to toggle source

platform method to retrieve the title for the current page See PageObject#title

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 57
def title
  @browser.title
end
uncheck_checkbox(identifier) click to toggle source

platform method to uncheck a checkbox See PageObject::Accessors#checkbox

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 356
def uncheck_checkbox(identifier)
  process_watir_call("checkbox(identifier).clear", Elements::CheckBox, identifier)
end
unordered_list_for(identifier) click to toggle source

platform method to retrieve an unordered list element See PageObject::Accessors#unordered_list

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 598
def unordered_list_for(identifier)
  find_watir_element("ul(identifier)", Elements::UnorderedList, identifier, 'ul')
end
unordered_list_text_for(identifier) click to toggle source

platform method to retrieve the text from an unordered list See PageObject::Accessors#unordered_list

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 590
def unordered_list_text_for(identifier)
  process_watir_call("ul(identifier).text", Elements::UnorderedList, identifier, nil, 'ul')
end
unordered_lists_for(identifier) click to toggle source

platform method to retrieve an array of unordered lists

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 605
def unordered_lists_for(identifier)
  find_watir_elements("uls(identifier)", Elements::UnorderedList, identifier, 'ul')
end
video_for(identifier) click to toggle source

platform method to retrieve a video element

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 901
def video_for(identifier)
  find_watir_element("video(identifier)", Elements::Video, identifier, 'video')
end
videos_for(identifier) click to toggle source

platform method to retrieve an array of video elements

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 908
def videos_for(identifier)
  find_watir_elements("videos(identifier)", Elements::Video, identifier, 'video')
end
wait_until(timeout, message = nil, &block) click to toggle source

platform method to wait for a block to return true See PageObject#wait_until

# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 64
def wait_until(timeout, message = nil, &block)
  @browser.wait_until(timeout, message, &block)
end

Private Instance Methods

add_tagname_if_needed(identifier, tag) click to toggle source
# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 972
def add_tagname_if_needed identifier, tag
  return identifier if identifier.length < 2 and not identifier[:name]
  identifier[:tag_name] = tag if identifier[:name]
  identifier
end
call_for_watir_element(identifier, call) click to toggle source
# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 1009
def call_for_watir_element(identifier, call)
  identifier[:css] ? "#{css_element}" : call
end
call_for_watir_elements(identifier, call) click to toggle source
# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 1013
def call_for_watir_elements(identifier, call)
  identifier[:css] ? "#{css_elements}" : call          
end
css_element() click to toggle source
# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 1001
def css_element
  "element(identifier)"
end
css_elements() click to toggle source
# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 1005
def css_elements
  "elements(identifier)"
end
find_watir_element(the_call, type, identifier, tag_name=nil) click to toggle source
# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 951
def find_watir_element(the_call, type, identifier, tag_name=nil)
  identifier, frame_identifiers = parse_identifiers(identifier, type, tag_name)
  element = @browser.instance_eval "#{nested_frames(frame_identifiers)}#{the_call}"
  switch_to_default_content(frame_identifiers)
  type.new(element, :platform => :watir_webdriver)
end
find_watir_elements(the_call, type, identifier, tag_name=nil) click to toggle source
# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 944
def find_watir_elements(the_call, type, identifier, tag_name=nil)
  identifier, frame_identifiers = parse_identifiers(identifier, type, tag_name)
  elements = @browser.instance_eval "#{nested_frames(frame_identifiers)}#{the_call}"
  switch_to_default_content(frame_identifiers)
  elements.map { |element| type.new(element, :platform => :watir_webdriver) }
end
nested_frames(frame_identifiers) click to toggle source
# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 978
def nested_frames(frame_identifiers)
  return if frame_identifiers.nil?
  frame_str = ''
  frame_identifiers.each do |frame|
    type = frame.keys.first
    identifier = frame.values.first.map do |key, value|
      if value.is_a?(Regexp)
        ":#{key} => #{value.inspect}"
      elsif value.to_s.is_integer
        ":#{key} => #{value}"
      else
        ":#{key} => '#{value}'"
      end
    end.join(', ')
    frame_str += "#{type.to_s}(#{identifier})."
  end
  frame_str
end
parse_identifiers(identifier, element, tag_name=nil) click to toggle source
# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 965
def parse_identifiers(identifier, element, tag_name=nil)
  frame_identifiers = identifier.delete(:frame)
  identifier = add_tagname_if_needed identifier, tag_name if tag_name
  identifier = element.watir_identifier_for identifier
  return identifier, frame_identifiers
end
process_watir_call(the_call, type, identifier, value=nil, tag_name=nil) click to toggle source
# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 958
def process_watir_call(the_call, type, identifier, value=nil, tag_name=nil)
  identifier, frame_identifiers = parse_identifiers(identifier, type, tag_name)
  value = @browser.instance_eval "#{nested_frames(frame_identifiers)}#{the_call}"
  switch_to_default_content(frame_identifiers)
  value
end
switch_to_default_content(frame_identifiers) click to toggle source
# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 997
def switch_to_default_content(frame_identifiers)
  @browser.wd.switch_to.default_content unless frame_identifiers.nil?          
end
switch_to_frame(frame_identifiers) click to toggle source
# File lib/page-object/platforms/watir_webdriver/page_object.rb, line 1017
def switch_to_frame(frame_identifiers)
  unless frame_identifiers.nil?
    frame_identifiers.each do |frame|
      frame_id = frame.values.first
      value = frame_id.values.first
      @browser.wd.switch_to.frame(value)
    end
  end          
end