Class: PageObject::Platforms::WatirWebDriver::PageObject

Inherits:
Object
  • Object
show all
Defined in:
lib/page-object/platforms/watir_webdriver/page_object.rb

Overview

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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(browser) ⇒ PageObject

Returns a new instance of PageObject.



17
18
19
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 17

def initialize(browser)
  @browser = browser
end

Instance Attribute Details

#browserObject (readonly)

Returns the value of attribute browser.



15
16
17
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 15

def browser
  @browser
end

Instance Method Details

#alert(frame = nil, &block) ⇒ Object

platform method to handle an alert popup See PageObject#alert



72
73
74
75
76
77
78
79
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 72

def alert(frame=nil, &block)
  switch_to_frame(frame)
  @browser.wd.execute_script "window.alert = function(msg) { window.__lastWatirAlert = msg; }"
  yield
  value = @browser.wd.execute_script "return window.__lastWatirAlert"
  switch_to_default_content(frame)
  value
end

#attach_to_window(identifier, &block) ⇒ Object

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



120
121
122
123
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 120

def attach_to_window(identifier, &block)
  win_id = {identifier.keys.first => /#{Regexp.escape(identifier.values.first)}/}
  @browser.window(win_id).use &block
end

#backObject

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



154
155
156
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 154

def back
  @browser.back
end

#button_for(identifier) ⇒ Object

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



465
466
467
468
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 465

def button_for(identifier)
  call = call_for_watir_element(identifier, "button(identifier)")
  find_watir_element(call, Elements::Button, identifier)
end

#buttons_for(identifier) ⇒ Object

platform method to retrieve an array of button elements



473
474
475
476
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 473

def buttons_for(identifier)
  call = call_for_watir_elements(identifier, "buttons(identifier)")
  find_watir_elements(call, Elements::Button, identifier)
end

#cell_for(identifier) ⇒ Object

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



506
507
508
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 506

def cell_for(identifier)
  find_watir_element("td(identifier)", Elements::TableCell, identifier, 'td')
end

#cell_text_for(identifier) ⇒ Object

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



497
498
499
500
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 497

def cell_text_for(identifier)
  process_watir_call("td(identifier).text", Elements::TableCell, identifier,
                     nil, 'td')
end

#cells_for(identifier) ⇒ Object

platform method to retrieve an array of table cell elements



513
514
515
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 513

def cells_for(identifier)
  find_watir_elements("tds(identifier)", Elements::TableCell, identifier, 'td')
end

#check_checkbox(identifier) ⇒ Object

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



332
333
334
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 332

def check_checkbox(identifier)
  process_watir_call("checkbox(identifier).set", Elements::CheckBox, identifier)
end

#checkbox_checked?(identifier) ⇒ Boolean

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

Returns:

  • (Boolean)


348
349
350
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 348

def checkbox_checked?(identifier)
  process_watir_call("checkbox(identifier).set?", Elements::CheckBox, identifier)
end

#checkbox_for(identifier) ⇒ Object

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



356
357
358
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 356

def checkbox_for(identifier)
  find_watir_element("checkbox(identifier)", Elements::CheckBox, identifier)
end

#checkboxes_for(identifier) ⇒ Object

platform method to retrieve an array of checkbox elements



363
364
365
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 363

def checkboxes_for(identifier)
  find_watir_elements("checkboxes(identifier)", Elements::CheckBox, identifier)
end

#clear_cookiesObject

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



170
171
172
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 170

def clear_cookies
  @browser.cookies.clear
end

#clear_radio(identifier) ⇒ Object

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



379
380
381
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 379

def clear_radio(identifier)
  process_watir_call("radio(identifier).clear", Elements::RadioButton, identifier)
end

#click_button_for(identifier) ⇒ Object

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



456
457
458
459
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 456

def click_button_for(identifier)
  call = call_for_watir_element(identifier, "button(identifier)")
  process_watir_call("#{call}.click", Elements::Button, identifier)
end

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



306
307
308
309
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 306

def click_link_for(identifier)
  call = call_for_watir_element(identifier, "link(identifier)")
  process_watir_call("#{call}.click if identifier", Elements::Link, identifier)
end

#confirm(response, frame = nil, &block) ⇒ Object

platform method to handle a confirm popup See PageObject#confirm



85
86
87
88
89
90
91
92
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 85

def confirm(response, frame=nil, &block)
  switch_to_frame(frame)
  @browser.wd.execute_script "window.confirm = function(msg) { window.__lastWatirConfirm = msg; return #{!!response} }"
  yield
  value = @browser.wd.execute_script "return window.__lastWatirConfirm"
  switch_to_default_content(frame)
  value
end

#current_urlObject

platform method to get the current url See PageObject#current_url



33
34
35
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 33

def current_url
  @browser.url
end

#div_for(identifier) ⇒ Object

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



418
419
420
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 418

def div_for(identifier)
  find_watir_element("div(identifier)", Elements::Div, identifier, 'div')
end

#div_text_for(identifier) ⇒ Object

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



410
411
412
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 410

def div_text_for(identifier)
  process_watir_call("div(identifier).text", Elements::Div, identifier, nil, 'div')
end

#divs_for(identifier) ⇒ Object

platform method to retrieve an array of div elements



425
426
427
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 425

def divs_for(identifier)
  find_watir_elements("divs(identifier)", Elements::Div, identifier, 'div')
end

#element_for(tag, identifier) ⇒ Object

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



814
815
816
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 814

def element_for(tag, identifier)
  find_watir_element("#{tag.to_s}(identifier)", Elements::Element, identifier, tag.to_s)
end

#element_with_focusObject



125
126
127
128
129
130
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 125

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) ⇒ Object



818
819
820
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 818

def elements_for(tag, identifier)
  find_watir_elements("#{tag.to_s}s(identifier)", Elements::Element, identifier, tag.to_s)
end

#execute_script(script) ⇒ Object

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



112
113
114
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 112

def execute_script(script)
  @browser.execute_script(script)
end

#file_field_for(identifier) ⇒ Object

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



798
799
800
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 798

def file_field_for(identifier)
  find_watir_element("file_field(identifier)", Elements::FileField, identifier)
end

#file_field_value_set(identifier, value) ⇒ Object

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



789
790
791
792
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 789

def file_field_value_set(identifier, value)
  process_watir_call("file_field(identifier).set(value)", Elements::FileField,
                     identifier, value)
end

#file_fields_for(identifier) ⇒ Object

platform method to retrieve an array of file field elements



805
806
807
808
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 805

def file_fields_for(identifier)
  find_watir_elements("file_fields(identifier)", Elements::FileField, identifier)
  
end

#form_for(identifier) ⇒ Object

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



536
537
538
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 536

def form_for(identifier)
  find_watir_element("form(identifier)", Elements::Form, identifier)
end

#forms_for(identifier) ⇒ Object

platform method to retrieve an array of forms



543
544
545
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 543

def forms_for(identifier)
  find_watir_elements("forms(identifier)", Elements::Form, identifier)
end

#forwardObject

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



162
163
164
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 162

def forward
  @browser.forward
end

#h1_for(identifier) ⇒ Object

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



612
613
614
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 612

def h1_for(identifier)
  find_watir_element("h1(identifier)", Elements::Heading, identifier, 'h1')
end

#h1_text_for(identifier) ⇒ Object

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



604
605
606
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 604

def h1_text_for(identifier)
  process_watir_call("h1(identifier).text", Elements::Heading, identifier, nil, 'h1')
end

#h1s_for(identifier) ⇒ Object

platform method to retrieve an array of h1s



619
620
621
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 619

def h1s_for(identifier)
  find_watir_elements("h1s(identifier)", Elements::Heading, identifier, 'h1')
end

#h2_for(identifier) ⇒ Object

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



635
636
637
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 635

def h2_for(identifier)
  find_watir_element("h2(identifier)", Elements::Heading, identifier, 'h2')
end

#h2_text_for(identifier) ⇒ Object

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



627
628
629
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 627

def h2_text_for(identifier)
  process_watir_call("h2(identifier).text", Elements::Heading, identifier, nil, 'h2')
end

#h2s_for(identifier) ⇒ Object

platform method to retrieve an array of h2s



642
643
644
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 642

def h2s_for(identifier)
  find_watir_elements("h2s(identifier)", Elements::Heading, identifier, 'h2')
end

#h3_for(identifier) ⇒ Object

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



658
659
660
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 658

def h3_for(identifier)
  find_watir_element("h3(identifier)", Elements::Heading, identifier, 'h3')
end

#h3_text_for(identifier) ⇒ Object

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



650
651
652
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 650

def h3_text_for(identifier)
  process_watir_call("h3(identifier).text", Elements::Heading, identifier, nil, 'h3')
end

#h3s_for(identifier) ⇒ Object

platform method to retrieve an array of h3s



665
666
667
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 665

def h3s_for(identifier)
  find_watir_elements("h3s(identifier)", Elements::Heading, identifier, 'h3')
end

#h4_for(identifier) ⇒ Object

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



681
682
683
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 681

def h4_for(identifier)
  find_watir_element("h4(identifier)", Elements::Heading, identifier, 'h4')
end

#h4_text_for(identifier) ⇒ Object

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



673
674
675
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 673

def h4_text_for(identifier)
  process_watir_call("h4(identifier).text", Elements::Heading, identifier, nil, 'h4')
end

#h4s_for(identifier) ⇒ Object

platform method to retrieve an array of h4s



688
689
690
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 688

def h4s_for(identifier)
  find_watir_elements("h4s(identifier)", Elements::Heading, identifier, 'h4')
end

#h5_for(identifier) ⇒ Object

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



704
705
706
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 704

def h5_for(identifier)
  find_watir_element("h5(identifier)", Elements::Heading, identifier, 'h5')
end

#h5_text_for(identifier) ⇒ Object

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



696
697
698
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 696

def h5_text_for(identifier)
  process_watir_call("h5(identifier).text", Elements::Heading, identifier, nil, 'h5')
end

#h5s_for(identifier) ⇒ Object

platform method to retrieve an array of h5s



711
712
713
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 711

def h5s_for(identifier)
  find_watir_elements("h5s(identifier)", Elements::Heading, identifier, 'h5')
end

#h6_for(identifier) ⇒ Object

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



727
728
729
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 727

def h6_for(identifier)
  find_watir_element("h6(identifier)", Elements::Heading, identifier, 'h6')
end

#h6_text_for(identifier) ⇒ Object

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



719
720
721
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 719

def h6_text_for(identifier)
  process_watir_call("h6(identifier).text", Elements::Heading, identifier, nil, 'h6')
end

#h6s_for(identifier) ⇒ Object

platform method to retrieve an array of h6s



734
735
736
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 734

def h6s_for(identifier)
  find_watir_elements("h6s(identifier)", Elements::Heading, identifier, 'h6')
end

#hidden_field_for(identifier) ⇒ Object

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



226
227
228
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 226

def hidden_field_for(identifier)
  find_watir_element("hidden(identifier)", Elements::HiddenField, identifier)
end

#hidden_field_value_for(identifier) ⇒ Object

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



218
219
220
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 218

def hidden_field_value_for(identifier)
  process_watir_call("hidden(identifier).value", Elements::HiddenField, identifier)
end

#hidden_fields_for(identifier) ⇒ Object

platform method to retrieve an array of hidden field elements



233
234
235
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 233

def hidden_fields_for(identifier)
  find_watir_elements("hiddens(identifier)", Elements::HiddenField, identifier)
end

#htmlObject

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



49
50
51
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 49

def html
  @browser.html
end

#image_for(identifier) ⇒ Object

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



521
522
523
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 521

def image_for(identifier)
  find_watir_element("image(identifier)", Elements::Image, identifier)
end

#images_for(identifier) ⇒ Object

platform method to retrieve an array of image elements



528
529
530
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 528

def images_for(identifier)
  find_watir_elements("images(identifier)", Elements::Image, identifier)
end

#in_frame(identifier, frame = nil, &block) ⇒ Object

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



136
137
138
139
140
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 136

def in_frame(identifier, frame=nil, &block)
  frame = [] if frame.nil?
  frame << identifier
  block.call(frame)
end

#label_for(identifier) ⇒ Object

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



773
774
775
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 773

def label_for(identifier)
  find_watir_element("label(identifier)", Elements::Label, identifier, 'label')
end

#label_text_for(identifier) ⇒ Object

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



765
766
767
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 765

def label_text_for(identifier)
  process_watir_call("label(identifier).text", Elements::Label, identifier, nil, 'label')
end

#labels_for(identifier) ⇒ Object

platform method to retrieve an array of label elements



781
782
783
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 781

def labels_for(identifier)
  find_watir_elements("labels(identifier)", Elements::Label, identifier, 'label')
end

platform method to return a PageObject::Elements::Link object see PageObject::Accessors#link



315
316
317
318
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 315

def link_for(identifier)
  call = call_for_watir_element(identifier, "link(identifier)")
  find_watir_element(call, Elements::Link, identifier)
end

platform method to retrieve an array of link elements



323
324
325
326
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 323

def links_for(identifier)
  call = call_for_watir_elements(identifier, "links(identifier)")
  find_watir_elements(call, Elements::Link, identifier)
end

#list_item_for(identifier) ⇒ Object

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



559
560
561
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 559

def list_item_for(identifier)
  find_watir_element("li(identifier)", Elements::ListItem, identifier, 'li')
end

#list_item_text_for(identifier) ⇒ Object

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



551
552
553
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 551

def list_item_text_for(identifier)
  process_watir_call("li(identifier).text", Elements::ListItem, identifier, nil, 'li')
end

#list_items_for(identifier) ⇒ Object

platform method to retrieve an array of list items



566
567
568
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 566

def list_items_for(identifier)
  find_watir_elements("lis(identifier)", Elements::ListItem, identifier, 'li')
end

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



25
26
27
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 25

def navigate_to(url)
  @browser.goto url
end

#ordered_list_for(identifier) ⇒ Object

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



589
590
591
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 589

def ordered_list_for(identifier)
  find_watir_element("ol(identifier)", Elements::OrderedList, identifier, 'ol')
end

#ordered_lists_for(identifier) ⇒ Object

platform method to retrieve an array of ordered lists



596
597
598
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 596

def ordered_lists_for(identifier)
  find_watir_elements("ols(identifier)", Elements::OrderedList, identifier, 'ol')
end

#paragraph_for(identifier) ⇒ Object

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



750
751
752
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 750

def paragraph_for(identifier)
  find_watir_element("p(identifier)", Elements::Paragraph, identifier, 'p')
end

#paragraph_text_for(identifier) ⇒ Object

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



742
743
744
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 742

def paragraph_text_for(identifier)
  process_watir_call("p(identifier).text", Elements::Paragraph, identifier, nil, 'p')
end

#paragraphs_for(identifier) ⇒ Object

platform method to retrieve an array of paragraph elements



757
758
759
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 757

def paragraphs_for(identifier)
  find_watir_elements("ps(identifier)", Elements::Paragraph, identifier, 'p')
end

#prompt(answer, frame = nil, &block) ⇒ Object

platform method to handle a prompt popup See PageObject#prompt



98
99
100
101
102
103
104
105
106
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 98

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) ⇒ Object

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



395
396
397
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 395

def radio_button_for(identifier)
  find_watir_element("radio(identifier)", Elements::RadioButton, identifier)
end

#radio_buttons_for(identifier) ⇒ Object

platform method to retrieve an array of radio button elements



402
403
404
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 402

def radio_buttons_for(identifier)
  find_watir_elements("radios(identifier)", Elements::RadioButton, identifier)
end

#radio_selected?(identifier) ⇒ Boolean

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

Returns:

  • (Boolean)


387
388
389
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 387

def radio_selected?(identifier)
  process_watir_call("radio(identifier).set?", Elements::RadioButton, identifier)
end

#refreshObject

platform method to refresh the page See PageObject#refresh



146
147
148
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 146

def refresh
  @browser.refresh
end

#save_screenshot(file_name) ⇒ Object

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



178
179
180
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 178

def save_screenshot(file_name)
  @browser.wd.save_screenshot(file_name)
end

#select_list_for(identifier) ⇒ Object

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



291
292
293
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 291

def select_list_for(identifier)
  find_watir_element("select_list(identifier)", Elements::SelectList, identifier)
end

#select_list_value_for(identifier) ⇒ Object

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



273
274
275
276
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 273

def select_list_value_for(identifier)
  process_watir_call("select_list(identifier).options.each {|o| return o.text if o.selected?}",
                     Elements::SelectList, identifier)
end

#select_list_value_set(identifier, value) ⇒ Object

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



282
283
284
285
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 282

def select_list_value_set(identifier, value)
  process_watir_call("select_list(identifier).select(value)", Elements::SelectList,
                     identifier, value)
end

#select_lists_for(identifier) ⇒ Object

platform method to retrieve an array of select_list elements



298
299
300
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 298

def select_lists_for(identifier)
  find_watir_elements("select_lists(identifier)", Elements::SelectList, identifier)
end

#select_radio(identifier) ⇒ Object

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



371
372
373
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 371

def select_radio(identifier)
  process_watir_call("radio(identifier).set", Elements::RadioButton, identifier)
end

#span_for(identifier) ⇒ Object

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



441
442
443
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 441

def span_for(identifier)
  find_watir_element("span(identifier)", Elements::Span, identifier, 'span')
end

#span_text_for(identifier) ⇒ Object

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



433
434
435
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 433

def span_text_for(identifier)
  process_watir_call("span(identifier).text", Elements::Span, identifier, nil, 'span')
end

#spans_for(identifier) ⇒ Object

platform method to retrieve an array of span elements



448
449
450
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 448

def spans_for(identifier)
  find_watir_elements("spans(identifier)", Elements::Span, identifier, 'span')
end

#table_for(identifier) ⇒ Object

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



482
483
484
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 482

def table_for(identifier)
  find_watir_element("table(identifier)", Elements::Table, identifier, 'table')
end

#tables_for(identifier) ⇒ Object

platform method to retrieve an array of table elements



489
490
491
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 489

def tables_for(identifier)
  find_watir_elements("tables(identifier)", Elements::Table, identifier, 'table')
end

#textObject

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



41
42
43
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 41

def text
  @browser.text
end

#text_area_for(identifier) ⇒ Object

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



258
259
260
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 258

def text_area_for(identifier)
  find_watir_element("textarea(identifier)", Elements::TextArea, identifier)
end

#text_area_value_for(identifier) ⇒ Object

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



250
251
252
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 250

def text_area_value_for(identifier)
  process_watir_call("textarea(identifier).value", Elements::TextArea, identifier)
end

#text_area_value_set(identifier, value) ⇒ Object

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



241
242
243
244
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 241

def text_area_value_set(identifier, value)
  process_watir_call("textarea(identifier).send_keys(value)", Elements::TextArea,
                     identifier, value)
end

#text_areas_for(identifier) ⇒ Object

platform method to retrieve an array of textarea elements



265
266
267
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 265

def text_areas_for(identifier)
  find_watir_elements("textareas(identifier)", Elements::TextArea, identifier)
end

#text_field_for(identifier) ⇒ Object

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



202
203
204
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 202

def text_field_for(identifier)
  find_watir_element("text_field(identifier)", Elements::TextField, identifier)
end

#text_field_value_for(identifier) ⇒ Object

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



186
187
188
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 186

def text_field_value_for(identifier)
  process_watir_call("text_field(identifier).value", Elements::TextField, identifier)
end

#text_field_value_set(identifier, value) ⇒ Object

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



194
195
196
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 194

def text_field_value_set(identifier, value)
  process_watir_call("text_field(identifier).set(value)", Elements::TextField, identifier, value)
end

#text_fields_for(identifier) ⇒ Object

platform method to retrieve an array of text field elements



209
210
211
212
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 209

def text_fields_for(identifier)
  elements = find_watir_elements("text_fields(identifier)", Elements::TextField, identifier)
  elements.select {|e| e.element.tag_name == 'input'}
end

#titleObject

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



57
58
59
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 57

def title
  @browser.title
end

#uncheck_checkbox(identifier) ⇒ Object

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



340
341
342
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 340

def uncheck_checkbox(identifier)
  process_watir_call("checkbox(identifier).clear", Elements::CheckBox, identifier)
end

#unordered_list_for(identifier) ⇒ Object

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



574
575
576
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 574

def unordered_list_for(identifier)
  find_watir_element("ul(identifier)", Elements::UnorderedList, identifier, 'ul')
end

#unordered_lists_for(identifier) ⇒ Object

platform method to retrieve an array of unordered lists



581
582
583
# File 'lib/page-object/platforms/watir_webdriver/page_object.rb', line 581

def unordered_lists_for(identifier)
  find_watir_elements("uls(identifier)", Elements::UnorderedList, identifier, 'ul')
end

#wait_until(timeout, message = nil, &block) ⇒ Object

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



64
65
66
# 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