Class: PageObject::Platforms::SeleniumWebDriver::PageObject
- Inherits:
-
Object
- Object
- PageObject::Platforms::SeleniumWebDriver::PageObject
- Defined in:
- lib/page-object/platforms/selenium_webdriver/page_object.rb
Overview
Selenium 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 Method Summary collapse
-
#alert(frame = nil, &block) ⇒ Object
platform method to handle an alert popup See PageObject#alert.
-
#attach_to_window(identifier, &block) ⇒ Object
platform method to handle attaching to a running window See PageObject#attach_to_window.
-
#back ⇒ Object
platform method to go back to the previous page See PageObject#back.
-
#button_for(identifier) ⇒ Object
platform method to retrieve a button element See PageObject::Accessors#button.
-
#buttons_for(identifier) ⇒ Object
platform method to retrieve an array of button elements.
-
#cell_for(identifier) ⇒ Object
platform method to retrieve a table cell element See PageObject::Accessors#cell.
-
#cell_text_for(identifier) ⇒ Object
platform method to retrieve the text from a table cell See PageObject::Accessors#cell.
-
#cells_for(identifier) ⇒ Object
platform method to retrieve all table cell elements.
-
#check_checkbox(identifier) ⇒ Object
platform method to check a checkbox See PageObject::Accessors#checkbox.
-
#checkbox_checked?(identifier) ⇒ Boolean
platform method to determine if a checkbox is checked See PageObject::Accessors#checkbox.
-
#checkbox_for(identifier) ⇒ Object
platform method to return a PageObject::Elements::CheckBox element See PageObject::Accessors#checkbox.
-
#checkboxes_for(identifier) ⇒ Object
platform method to retrieve all checkbox elements.
-
#clear_cookies ⇒ Object
platform method to clear the cookies from the browser See PageObject#clear_cookies.
-
#clear_radio(identifier) ⇒ Object
platform method to clear a radio button See PageObject::Accessors#radio_button.
-
#click_button_for(identifier) ⇒ Object
platform method to click a button See PageObject::Accessors#button.
-
#click_link_for(identifier) ⇒ Object
platform method to click a link See PageObject::Accessors#link.
-
#confirm(response, frame = nil, &block) ⇒ Object
platform method to handle a confirm popup See PageObject#confirm.
-
#current_url ⇒ Object
platform method to get the current url See PageObject#current_url.
-
#div_for(identifier) ⇒ Object
platform method to return a PageObject::Elements::Div element See PageObject::Accessors#div.
-
#div_text_for(identifier) ⇒ Object
platform method to return the text for a div See PageObject::Accessors#div.
-
#divs_for(identifier) ⇒ Object
platform method to retrieve all div elements.
-
#element_for(tag, identifier) ⇒ Object
platform method to retrieve a generic element See PageObject::Accessors#element.
-
#element_with_focus ⇒ Object
find the element that has focus.
-
#elements_for(tag, identifier) ⇒ Object
platform method to retrieve a collection of generic elements See PageObject::Accessors#elements.
-
#execute_script(script) ⇒ Object
platform method to execute javascript on the browser See PageObject#execute_script.
-
#file_field_for(identifier) ⇒ Object
platform method to retrieve a file_field element See PageObject::Accessors#file_field.
-
#file_field_value_set(identifier, value) ⇒ Object
platform method to set the file on a file_field element See PageObject::Accessors#file_field.
-
#file_fields_for(identifier) ⇒ Object
platform method to return an array of file field elements.
-
#form_for(identifier) ⇒ Object
platform method to retrieve a form element See PageObject::Accessors#form.
-
#forms_for(identifier) ⇒ Object
platform method to retrieve all forms.
-
#forward ⇒ Object
platform method to go forward to the next page See PageObject#forward.
-
#h1_for(identifier) ⇒ Object
platform method to retrieve the h1 element See PageObject::Accessors#h1.
-
#h1_text_for(identifier) ⇒ Object
platform method to retrieve the text from a h1 See PageObject::Accessors#h1.
-
#h1s_for(identifier) ⇒ Object
platform method to retrieve all h1 elements.
-
#h2_for(identifier) ⇒ Object
platform method to retrieve the h2 element See PageObject::Accessors#h2.
-
#h2_text_for(identifier) ⇒ Object
platform method to retrieve the text from a h2 See PageObject::Accessors#h2.
-
#h2s_for(identifier) ⇒ Object
platform method to retrieve all h2 elements.
-
#h3_for(identifier) ⇒ Object
platform method to retrieve the h3 element See PageObject::Accessors#h3.
-
#h3_text_for(identifier) ⇒ Object
platform method to retrieve the text from a h3 See PageObject::Accessors#h3.
-
#h3s_for(identifier) ⇒ Object
platform method to retrieve all h3 elements.
-
#h4_for(identifier) ⇒ Object
platform method to retrieve the h4 element See PageObject::Accessors#h4.
-
#h4_text_for(identifier) ⇒ Object
platform method to retrieve the text from a h4 See PageObject::Accessors#h4.
-
#h4s_for(identifier) ⇒ Object
platform method to retrieve all h4 elements.
-
#h5_for(identifier) ⇒ Object
platform method to retrieve the h5 element See PageObject::Accessors#h5.
-
#h5_text_for(identifier) ⇒ Object
platform method to retrieve the text from a h5 See PageObject::Accessors#h5.
-
#h5s_for(identifier) ⇒ Object
platform method to retrieve all h5 elements.
-
#h6_for(identifier) ⇒ Object
platform method to retrieve the h6 element See PageObject::Accessors#h6.
-
#h6_text_for(identifier) ⇒ Object
platform method to retrieve the text from a h6 See PageObject::Accessors#h6.
-
#h6s_for(identifier) ⇒ Object
platform method to retrieve all h6 elements.
-
#hidden_field_for(identifier) ⇒ Object
platform method to retrieve a hidden field element See PageObject::Accessors#hidden_field.
-
#hidden_field_value_for(identifier) ⇒ Object
platform method to get the value stored in a hidden field See PageObject::Accessors#hidden_field.
-
#hidden_fields_for(identifier) ⇒ Object
platform method to retrieve all hidden field elements.
-
#html ⇒ Object
platform method to retrieve the html for the current page See PageObject#html.
-
#image_for(identifier) ⇒ Object
platform method to retrieve an image element See PageObject::Accessors#image.
-
#images_for(identifier) ⇒ Object
platform method to retrieve all image elements.
-
#in_frame(identifier, frame = nil, &block) ⇒ Object
platform method to switch to a frame and execute a block See PageObject#in_frame.
-
#initialize(browser) ⇒ PageObject
constructor
A new instance of PageObject.
-
#label_for(identifier) ⇒ Object
platform method to return a PageObject::Elements::Label element See PageObject::Accessors#label.
-
#label_text_for(identifier) ⇒ Object
platform method to return the text for a label See PageObject::Accessors#label.
-
#labels_for(identifier) ⇒ Object
platform method to retrieve all label elements.
-
#link_for(identifier) ⇒ Object
platform method to return a PageObject::Elements::Link object see PageObject::Accessors#link.
-
#links_for(identifier) ⇒ Object
platform method to retrieve all link elements.
-
#list_item_for(identifier) ⇒ Object
platform method to retrieve a list item element See PageObject::Accessors#list_item.
-
#list_item_text_for(identifier) ⇒ Object
platform method to retrieve the text from a list item See PageObject::Accessors#list_item.
-
#list_items_for(identifier) ⇒ Object
platform method to retrieve all list items.
-
#navigate_to(url) ⇒ Object
platform method to navigate to a provided url See PageObject#navigate_to.
-
#ordered_list_for(identifier) ⇒ Object
platform method to retrieve an ordered list element See PageObject::Accessors#ordered_list.
-
#ordered_lists_for(identifier) ⇒ Object
platform method to retrieve all ordered lists.
-
#paragraph_for(identifier) ⇒ Object
platform method to retrieve the paragraph element See PageObject::Accessors#paragraph.
-
#paragraph_text_for(identifier) ⇒ Object
platform method to retrieve the text for a paragraph See PageObject::Accessors#paragraph.
-
#paragraphs_for(identifier) ⇒ Object
platform method to retrieve all paragraph elements.
-
#prompt(answer, frame = nil, &block) ⇒ Object
platform method to handle a prompt popup See PageObject#prompt.
-
#radio_button_for(identifier) ⇒ Object
platform method to return a PageObject::Eements::RadioButton element See PageObject::Accessors#radio_button.
-
#radio_buttons_for(identifier) ⇒ Object
platform method to retrieve all radio button elements.
-
#radio_selected?(identifier) ⇒ Boolean
platform method to determine if a radio button is selected See PageObject::Accessors#radio_button.
-
#refresh ⇒ Object
platform method to refresh the page See PageObject#refresh.
-
#save_screenshot(file_name) ⇒ Object
platform method to save the current screenshot to a file See PageObject#save_screenshot.
-
#select_list_for(identifier) ⇒ Object
platform method to return the select list element See PageObject::Accessors#select_list.
-
#select_list_value_for(identifier) ⇒ Object
platform method to get the currently selected value from a select list See PageObject::Accessors#select_list.
-
#select_list_value_set(identifier, value) ⇒ Object
platform method to select a value from a select list See PageObject::Accessors#select_list.
-
#select_lists_for(identifier) ⇒ Object
platform method to retrieve all select list elements.
-
#select_radio(identifier) ⇒ Object
platform method to select a radio button See PageObject::Accessors#radio_button.
-
#span_for(identifier) ⇒ Object
platform method to return a PageObject::Elements::Span element See PageObject::Accessors#span.
-
#span_text_for(identifier) ⇒ Object
platform method to return the text for a span See PageObject::Accessors#span.
-
#spans_for(identifier) ⇒ Object
platform method to retrieve all span elements.
-
#table_for(identifier) ⇒ Object
platform method to retrieve a table element See PageObject::Accessors#table.
-
#tables_for(identifier) ⇒ Object
platform method to retrieve all table elements.
-
#text ⇒ Object
platform method to retrieve the text from the current page See PageObject#text.
-
#text_area_for(identifier) ⇒ Object
platform method to get the text area element See PageObject::Accessors#text_area.
-
#text_area_value_for(identifier) ⇒ Object
platform method to get the text from a textarea See PageObject::Accessors#text_area.
-
#text_area_value_set(identifier, value) ⇒ Object
platform method to set text in a textarea See PageObject::Accessors#text_area.
-
#text_areas_for(identifier) ⇒ Object
platform method to retrieve all text area elements.
-
#text_field_for(identifier) ⇒ Object
platform method to retrieve a text field element See PageObject::Accessors#text_field.
-
#text_field_value_for(identifier) ⇒ Object
platform method to get the value stored in a text field See PageObject::Accessors#text_field.
-
#text_field_value_set(identifier, value) ⇒ Object
platform method to set the value for a text field See PageObject::Accessors#text_field.
-
#text_fields_for(identifier) ⇒ Object
platform method to retrieve all text field elements.
-
#title ⇒ Object
platform method to retrieve the title for the current page See PageObject#title.
-
#uncheck_checkbox(identifier) ⇒ Object
platform method to uncheck a checkbox See PageObject::Accessors#checkbox.
-
#unordered_list_for(identifier) ⇒ Object
platform method to retrieve an unordered list element See PageObject::Accessors#unordered_list.
-
#unordered_lists_for(identifier) ⇒ Object
platform method to retrieve all unordered lists.
-
#wait_until(timeout, message = nil, &block) ⇒ Object
platform method to wait for a block to return true See PageObject#wait_until.
Constructor Details
#initialize(browser) ⇒ PageObject
Returns a new instance of PageObject.
15 16 17 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 15 def initialize(browser) @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 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 72 def alert(frame=nil, &block) @browser.execute_script "window.alert = function(msg) { window.__lastWatirAlert = msg; }" yield @browser.execute_script "return window.__lastWatirAlert" end |
#attach_to_window(identifier, &block) ⇒ Object
platform method to handle attaching to a running window See PageObject#attach_to_window
112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 112 def attach_to_window(identifier, &block) value = identifier.values.first key = identifier.keys.first handles = @browser.window_handles handles.each do |handle| @browser.switch_to.window handle if (key == :title and value == @browser.title) or (key == :url and value == @browser.current_url) return @browser.switch_to.window handle, &block end end end |
#back ⇒ Object
platform method to go back to the previous page See PageObject#back
157 158 159 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 157 def back @browser.navigate.back end |
#button_for(identifier) ⇒ Object
platform method to retrieve a button element See PageObject::Accessors#button
498 499 500 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 498 def (identifier) find_selenium_element(identifier, Elements::Button, 'input', :type => 'submit') end |
#buttons_for(identifier) ⇒ Object
platform method to retrieve an array of button elements
505 506 507 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 505 def (identifier) find_selenium_elements(identifier, Elements::Button, 'input', :type => 'submit') end |
#cell_for(identifier) ⇒ Object
platform method to retrieve a table cell element See PageObject::Accessors#cell
538 539 540 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 538 def cell_for(identifier) find_selenium_element(identifier, Elements::TableCell, 'td') end |
#cell_text_for(identifier) ⇒ Object
platform method to retrieve the text from a table cell See PageObject::Accessors#cell
528 529 530 531 532 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 528 def cell_text_for(identifier) process_selenium_call(identifier, Elements::TableCell, 'td') do |how, what| @browser.find_element(how, what).text end end |
#cells_for(identifier) ⇒ Object
platform method to retrieve all table cell elements
545 546 547 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 545 def cells_for(identifier) find_selenium_elements(identifier, Elements::TableCell, 'td') end |
#check_checkbox(identifier) ⇒ Object
platform method to check a checkbox See PageObject::Accessors#checkbox
348 349 350 351 352 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 348 def check_checkbox(identifier) process_selenium_call(identifier, Elements::CheckBox, 'input', :type => 'checkbox') do |how, what| @browser.find_element(how, what).click unless @browser.find_element(how, what).selected? end end |
#checkbox_checked?(identifier) ⇒ Boolean
platform method to determine if a checkbox is checked See PageObject::Accessors#checkbox
368 369 370 371 372 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 368 def checkbox_checked?(identifier) process_selenium_call(identifier, Elements::CheckBox, 'input', :type => 'checkbox') do |how, what| @browser.find_element(how, what).selected? end end |
#checkbox_for(identifier) ⇒ Object
platform method to return a PageObject::Elements::CheckBox element See PageObject::Accessors#checkbox
378 379 380 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 378 def checkbox_for(identifier) find_selenium_element(identifier, Elements::CheckBox, 'input', :type => 'checkbox') end |
#checkboxes_for(identifier) ⇒ Object
platform method to retrieve all checkbox elements
385 386 387 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 385 def checkboxes_for(identifier) find_selenium_elements(identifier, Elements::CheckBox, 'input', :type => 'checkbox') end |
#clear_cookies ⇒ Object
platform method to clear the cookies from the browser See PageObject#clear_cookies
173 174 175 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 173 def @browser.manage. end |
#clear_radio(identifier) ⇒ Object
platform method to clear a radio button See PageObject::Accessors#radio_button
403 404 405 406 407 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 403 def clear_radio(identifier) process_selenium_call(identifier, Elements::RadioButton, 'input', :type => 'radio') do |how, what| @browser.find_element(how, what).click if @browser.find_element(how, what).selected? end end |
#click_button_for(identifier) ⇒ Object
platform method to click a button See PageObject::Accessors#button
488 489 490 491 492 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 488 def (identifier) process_selenium_call(identifier, Elements::Button, 'input', :type => 'submit') do |how, what| @browser.find_element(how, what).click end end |
#click_link_for(identifier) ⇒ Object
platform method to click a link See PageObject::Accessors#link
323 324 325 326 327 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 323 def click_link_for(identifier) process_selenium_call(identifier, Elements::Link, 'a') do |how, what| @browser.find_element(how, what).click end end |
#confirm(response, frame = nil, &block) ⇒ Object
platform method to handle a confirm popup See PageObject#confirm
82 83 84 85 86 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 82 def confirm(response, frame=nil, &block) @browser.execute_script "window.confirm = function(msg) { window.__lastWatirConfirm = msg; return #{!!response} }" yield @browser.execute_script "return window.__lastWatirConfirm" end |
#current_url ⇒ Object
platform method to get the current url See PageObject#current_url
31 32 33 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 31 def current_url @browser.current_url end |
#div_for(identifier) ⇒ Object
platform method to return a PageObject::Elements::Div element See PageObject::Accessors#div
448 449 450 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 448 def div_for(identifier) find_selenium_element(identifier, Elements::Div, 'div') end |
#div_text_for(identifier) ⇒ Object
platform method to return the text for a div See PageObject::Accessors#div
438 439 440 441 442 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 438 def div_text_for(identifier) process_selenium_call(identifier, Elements::Div, 'div') do |how, what| @browser.find_element(how, what).text end end |
#divs_for(identifier) ⇒ Object
platform method to retrieve all div elements
455 456 457 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 455 def divs_for(identifier) find_selenium_elements(identifier, Elements::Div, 'div') end |
#element_for(tag, identifier) ⇒ Object
platform method to retrieve a generic element See PageObject::Accessors#element
865 866 867 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 865 def element_for(tag, identifier) find_selenium_element(identifier, Elements::FileField, tag.to_s) end |
#element_with_focus ⇒ Object
find the element that has focus
128 129 130 131 132 133 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 128 def element_with_focus element = @browser.execute_script("return document.activeElement") type = element.attribute(:type).to_s.downcase if element.tag_name.to_sym == :input cls = ::PageObject::Elements.element_class_for(element.tag_name, type) cls.new(element, :platform => :selenium_webdriver) end |
#elements_for(tag, identifier) ⇒ Object
platform method to retrieve a collection of generic elements See PageObject::Accessors#elements
873 874 875 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 873 def elements_for(tag, identifier) find_selenium_elements(identifier, Elements::FileField, tag.to_s) end |
#execute_script(script) ⇒ Object
platform method to execute javascript on the browser See PageObject#execute_script
104 105 106 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 104 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
850 851 852 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 850 def file_field_for(identifier) find_selenium_element(identifier, Elements::FileField, 'input', :type => 'file') end |
#file_field_value_set(identifier, value) ⇒ Object
platform method to set the file on a file_field element See PageObject::Accessors#file_field
840 841 842 843 844 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 840 def file_field_value_set(identifier, value) process_selenium_call(identifier, Elements::FileField, 'input', :type => 'file') do |how, what| @browser.find_element(how, what).send_keys(value) end end |
#file_fields_for(identifier) ⇒ Object
platform method to return an array of file field elements
857 858 859 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 857 def file_fields_for(identifier) find_selenium_elements(identifier, Elements::FileField, 'input', :type => 'file') end |
#form_for(identifier) ⇒ Object
platform method to retrieve a form element See PageObject::Accessors#form
568 569 570 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 568 def form_for(identifier) find_selenium_element(identifier, Elements::Form, 'form') end |
#forms_for(identifier) ⇒ Object
platform method to retrieve all forms
575 576 577 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 575 def forms_for(identifier) find_selenium_elements(identifier, Elements::Form, 'form') end |
#forward ⇒ Object
platform method to go forward to the next page See PageObject#forward
165 166 167 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 165 def forward @browser.navigate.forward end |
#h1_for(identifier) ⇒ Object
platform method to retrieve the h1 element See PageObject::Accessors#h1
648 649 650 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 648 def h1_for(identifier) find_selenium_element(identifier, Elements::Heading, 'h1') end |
#h1_text_for(identifier) ⇒ Object
platform method to retrieve the text from a h1 See PageObject::Accessors#h1
638 639 640 641 642 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 638 def h1_text_for(identifier) process_selenium_call(identifier, Elements::Heading, 'h1') do |how, what| @browser.find_element(how, what).text end end |
#h1s_for(identifier) ⇒ Object
platform method to retrieve all h1 elements
655 656 657 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 655 def h1s_for(identifier) find_selenium_elements(identifier, Elements::Heading, 'h1') end |
#h2_for(identifier) ⇒ Object
platform method to retrieve the h2 element See PageObject::Accessors#h2
673 674 675 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 673 def h2_for(identifier) find_selenium_element(identifier, Elements::Heading, 'h2') end |
#h2_text_for(identifier) ⇒ Object
platform method to retrieve the text from a h2 See PageObject::Accessors#h2
663 664 665 666 667 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 663 def h2_text_for(identifier) process_selenium_call(identifier, Elements::Heading, 'h2') do |how, what| @browser.find_element(how, what).text end end |
#h2s_for(identifier) ⇒ Object
platform method to retrieve all h2 elements
680 681 682 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 680 def h2s_for(identifier) find_selenium_elements(identifier, Elements::Heading, 'h2') end |
#h3_for(identifier) ⇒ Object
platform method to retrieve the h3 element See PageObject::Accessors#h3
698 699 700 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 698 def h3_for(identifier) find_selenium_element(identifier, Elements::Heading, 'h3') end |
#h3_text_for(identifier) ⇒ Object
platform method to retrieve the text from a h3 See PageObject::Accessors#h3
688 689 690 691 692 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 688 def h3_text_for(identifier) process_selenium_call(identifier, Elements::Heading, 'h3') do |how, what| @browser.find_element(how, what).text end end |
#h3s_for(identifier) ⇒ Object
platform method to retrieve all h3 elements
705 706 707 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 705 def h3s_for(identifier) find_selenium_elements(identifier, Elements::Heading, 'h3') end |
#h4_for(identifier) ⇒ Object
platform method to retrieve the h4 element See PageObject::Accessors#h4
723 724 725 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 723 def h4_for(identifier) find_selenium_element(identifier, Elements::Heading, 'h4') end |
#h4_text_for(identifier) ⇒ Object
platform method to retrieve the text from a h4 See PageObject::Accessors#h4
713 714 715 716 717 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 713 def h4_text_for(identifier) process_selenium_call(identifier, Elements::Heading, 'h4') do |how, what| @browser.find_element(how, what).text end end |
#h4s_for(identifier) ⇒ Object
platform method to retrieve all h4 elements
730 731 732 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 730 def h4s_for(identifier) find_selenium_elements(identifier, Elements::Heading, 'h4') end |
#h5_for(identifier) ⇒ Object
platform method to retrieve the h5 element See PageObject::Accessors#h5
748 749 750 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 748 def h5_for(identifier) find_selenium_element(identifier, Elements::Heading, 'h5') end |
#h5_text_for(identifier) ⇒ Object
platform method to retrieve the text from a h5 See PageObject::Accessors#h5
738 739 740 741 742 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 738 def h5_text_for(identifier) process_selenium_call(identifier, Elements::Heading, 'h5') do |how, what| @browser.find_element(how, what).text end end |
#h5s_for(identifier) ⇒ Object
platform method to retrieve all h5 elements
755 756 757 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 755 def h5s_for(identifier) find_selenium_elements(identifier, Elements::Heading, 'h5') end |
#h6_for(identifier) ⇒ Object
platform method to retrieve the h6 element See PageObject::Accessors#h6
773 774 775 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 773 def h6_for(identifier) find_selenium_element(identifier, Elements::Heading, 'h6') end |
#h6_text_for(identifier) ⇒ Object
platform method to retrieve the text from a h6 See PageObject::Accessors#h6
763 764 765 766 767 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 763 def h6_text_for(identifier) process_selenium_call(identifier, Elements::Heading, 'h6') do |how, what| @browser.find_element(how, what).text end end |
#h6s_for(identifier) ⇒ Object
platform method to retrieve all h6 elements
780 781 782 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 780 def h6s_for(identifier) find_selenium_elements(identifier, Elements::Heading, 'h6') end |
#hidden_field_for(identifier) ⇒ Object
platform method to retrieve a hidden field element See PageObject::Accessors#hidden_field
236 237 238 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 236 def hidden_field_for(identifier) find_selenium_element(identifier, Elements::HiddenField, 'input', :type => 'hidden') end |
#hidden_field_value_for(identifier) ⇒ Object
platform method to get the value stored in a hidden field See PageObject::Accessors#hidden_field
226 227 228 229 230 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 226 def hidden_field_value_for(identifier) process_selenium_call(identifier, Elements::HiddenField, 'input', :type => 'hidden') do |how, what| @browser.find_element(how, what).attribute('value') end end |
#hidden_fields_for(identifier) ⇒ Object
platform method to retrieve all hidden field elements
243 244 245 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 243 def hidden_fields_for(identifier) find_selenium_elements(identifier, Elements::HiddenField, 'input', :type => 'hidden') end |
#html ⇒ Object
platform method to retrieve the html for the current page See PageObject#html
47 48 49 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 47 def html @browser.page_source end |
#image_for(identifier) ⇒ Object
platform method to retrieve an image element See PageObject::Accessors#image
553 554 555 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 553 def image_for(identifier) find_selenium_element(identifier, Elements::Image, 'img') end |
#images_for(identifier) ⇒ Object
platform method to retrieve all image elements
560 561 562 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 560 def images_for(identifier) find_selenium_elements(identifier, Elements::Image, 'img') end |
#in_frame(identifier, frame = nil, &block) ⇒ Object
platform method to switch to a frame and execute a block See PageObject#in_frame
139 140 141 142 143 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 139 def in_frame(identifier, frame=nil, &block) switch_to_frame([identifier]) block.call(nil) @browser.switch_to.default_content end |
#label_for(identifier) ⇒ Object
platform method to return a PageObject::Elements::Label element See PageObject::Accessors#label
824 825 826 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 824 def label_for(identifier) find_selenium_element(identifier, Elements::Label, 'label') end |
#label_text_for(identifier) ⇒ Object
platform method to return the text for a label See PageObject::Accessors#label
813 814 815 816 817 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 813 def label_text_for(identifier) process_selenium_call(identifier, Elements::Label, 'label') do |how, what| @browser.find_element(how, what).text end end |
#labels_for(identifier) ⇒ Object
platform method to retrieve all label elements
832 833 834 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 832 def labels_for(identifier) find_selenium_elements(identifier, Elements::Label, 'label') end |
#link_for(identifier) ⇒ Object
platform method to return a PageObject::Elements::Link object see PageObject::Accessors#link
333 334 335 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 333 def link_for(identifier) find_selenium_element(identifier, Elements::Link, 'a') end |
#links_for(identifier) ⇒ Object
platform method to retrieve all link elements
340 341 342 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 340 def links_for(identifier) find_selenium_elements(identifier, Elements::Link, 'a') end |
#list_item_for(identifier) ⇒ Object
platform method to retrieve a list item element See PageObject::Accessors#list_item
593 594 595 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 593 def list_item_for(identifier) find_selenium_element(identifier, Elements::ListItem, 'li') end |
#list_item_text_for(identifier) ⇒ Object
platform method to retrieve the text from a list item See PageObject::Accessors#list_item
583 584 585 586 587 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 583 def list_item_text_for(identifier) process_selenium_call(identifier, Elements::ListItem, 'li') do |how, what| @browser.find_element(how, what).text end end |
#list_items_for(identifier) ⇒ Object
platform method to retrieve all list items
600 601 602 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 600 def list_items_for(identifier) find_selenium_elements(identifier, Elements::ListItem, 'li') end |
#navigate_to(url) ⇒ Object
platform method to navigate to a provided url See PageObject#navigate_to
23 24 25 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 23 def navigate_to(url) @browser.navigate.to url end |
#ordered_list_for(identifier) ⇒ Object
platform method to retrieve an ordered list element See PageObject::Accessors#ordered_list
623 624 625 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 623 def ordered_list_for(identifier) find_selenium_element(identifier, Elements::OrderedList, 'ol') end |
#ordered_lists_for(identifier) ⇒ Object
platform method to retrieve all ordered lists
630 631 632 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 630 def ordered_lists_for(identifier) find_selenium_elements(identifier, Elements::OrderedList, 'ol') end |
#paragraph_for(identifier) ⇒ Object
platform method to retrieve the paragraph element See PageObject::Accessors#paragraph
798 799 800 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 798 def paragraph_for(identifier) find_selenium_element(identifier, Elements::Paragraph, 'p') end |
#paragraph_text_for(identifier) ⇒ Object
platform method to retrieve the text for a paragraph See PageObject::Accessors#paragraph
788 789 790 791 792 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 788 def paragraph_text_for(identifier) process_selenium_call(identifier, Elements::Paragraph, 'p') do |how, what| @browser.find_element(how, what).text end end |
#paragraphs_for(identifier) ⇒ Object
platform method to retrieve all paragraph elements
805 806 807 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 805 def paragraphs_for(identifier) find_selenium_elements(identifier, Elements::Paragraph, 'p') end |
#prompt(answer, frame = nil, &block) ⇒ Object
platform method to handle a prompt popup See PageObject#prompt
92 93 94 95 96 97 98 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 92 def prompt(answer, frame=nil, &block) @browser.execute_script "window.prompt = function(text, value) { window.__lastWatirPrompt = { message: text, default_value: value }; return #{answer}; }" yield result = @browser.execute_script "return window.__lastWatirPrompt" 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
423 424 425 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 423 def (identifier) find_selenium_element(identifier, Elements::RadioButton, 'input', :type => 'radio') end |
#radio_buttons_for(identifier) ⇒ Object
platform method to retrieve all radio button elements
430 431 432 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 430 def (identifier) find_selenium_elements(identifier, Elements::RadioButton, 'input', :type => 'radio') end |
#radio_selected?(identifier) ⇒ Boolean
platform method to determine if a radio button is selected See PageObject::Accessors#radio_button
413 414 415 416 417 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 413 def radio_selected?(identifier) process_selenium_call(identifier, Elements::RadioButton, 'input', :type => 'radio') do |how, what| @browser.find_element(how, what).selected? end end |
#refresh ⇒ Object
platform method to refresh the page See PageObject#refresh
149 150 151 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 149 def refresh @browser.navigate.refresh end |
#save_screenshot(file_name) ⇒ Object
platform method to save the current screenshot to a file See PageObject#save_screenshot
181 182 183 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 181 def save_screenshot(file_name) @browser.save_screenshot(file_name) end |
#select_list_for(identifier) ⇒ Object
platform method to return the select list element See PageObject::Accessors#select_list
308 309 310 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 308 def select_list_for(identifier) find_selenium_element(identifier, Elements::SelectList, 'select') end |
#select_list_value_for(identifier) ⇒ Object
platform method to get the currently selected value from a select list See PageObject::Accessors#select_list
286 287 288 289 290 291 292 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 286 def select_list_value_for(identifier) process_selenium_call(identifier, Elements::SelectList, 'select') do |how, what| @browser.find_element(how, what).find_elements(:tag_name => 'option').each do |o| return o.text if o.selected? end end end |
#select_list_value_set(identifier, value) ⇒ Object
platform method to select a value from a select list See PageObject::Accessors#select_list
298 299 300 301 302 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 298 def select_list_value_set(identifier, value) process_selenium_call(identifier, Elements::SelectList, 'select') do |how, what| @browser.find_element(how, what).send_keys(value) end end |
#select_lists_for(identifier) ⇒ Object
platform method to retrieve all select list elements
315 316 317 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 315 def select_lists_for(identifier) find_selenium_elements(identifier, Elements::SelectList, 'select') end |
#select_radio(identifier) ⇒ Object
platform method to select a radio button See PageObject::Accessors#radio_button
393 394 395 396 397 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 393 def select_radio(identifier) process_selenium_call(identifier, Elements::RadioButton, 'input', :type => 'radio') do |how, what| @browser.find_element(how, what).click unless @browser.find_element(how, what).selected? end end |
#span_for(identifier) ⇒ Object
platform method to return a PageObject::Elements::Span element See PageObject::Accessors#span
473 474 475 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 473 def span_for(identifier) find_selenium_element(identifier, Elements::Span, 'span') end |
#span_text_for(identifier) ⇒ Object
platform method to return the text for a span See PageObject::Accessors#span
463 464 465 466 467 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 463 def span_text_for(identifier) process_selenium_call(identifier, Elements::Span, 'span') do |how, what| @browser.find_element(how, what).text end end |
#spans_for(identifier) ⇒ Object
platform method to retrieve all span elements
480 481 482 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 480 def spans_for(identifier) find_selenium_elements(identifier, Elements::Span, 'span') end |
#table_for(identifier) ⇒ Object
platform method to retrieve a table element See PageObject::Accessors#table
513 514 515 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 513 def table_for(identifier) find_selenium_element(identifier, Elements::Table, 'table') end |
#tables_for(identifier) ⇒ Object
platform method to retrieve all table elements
520 521 522 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 520 def tables_for(identifier) find_selenium_elements(identifier, Elements::Table, 'table') end |
#text ⇒ Object
platform method to retrieve the text from the current page See PageObject#text
39 40 41 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 39 def text @browser.find_element(:tag_name, 'body').text end |
#text_area_for(identifier) ⇒ Object
platform method to get the text area element See PageObject::Accessors#text_area
271 272 273 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 271 def text_area_for(identifier) find_selenium_element(identifier, Elements::TextArea, 'textarea') end |
#text_area_value_for(identifier) ⇒ Object
platform method to get the text from a textarea See PageObject::Accessors#text_area
261 262 263 264 265 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 261 def text_area_value_for(identifier) process_selenium_call(identifier, Elements::TextArea, 'textarea') do |how, what| @browser.find_element(how, what).attribute('value') end end |
#text_area_value_set(identifier, value) ⇒ Object
platform method to set text in a textarea See PageObject::Accessors#text_area
251 252 253 254 255 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 251 def text_area_value_set(identifier, value) process_selenium_call(identifier, Elements::TextArea, 'textarea') do |how, what| @browser.find_element(how, what).send_keys(value) end end |
#text_areas_for(identifier) ⇒ Object
platform method to retrieve all text area elements
278 279 280 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 278 def text_areas_for(identifier) find_selenium_elements(identifier, Elements::TextArea, 'textarea') end |
#text_field_for(identifier) ⇒ Object
platform method to retrieve a text field element See PageObject::Accessors#text_field
211 212 213 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 211 def text_field_for(identifier) find_selenium_element(identifier, Elements::TextField, 'input', :type => 'text') end |
#text_field_value_for(identifier) ⇒ Object
platform method to get the value stored in a text field See PageObject::Accessors#text_field
189 190 191 192 193 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 189 def text_field_value_for(identifier) process_selenium_call(identifier, Elements::TextField, 'input', :type => 'text') do |how, what| @browser.find_element(how, what).attribute('value') end end |
#text_field_value_set(identifier, value) ⇒ Object
platform method to set the value for a text field See PageObject::Accessors#text_field
200 201 202 203 204 205 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 200 def text_field_value_set(identifier, value) process_selenium_call(identifier, Elements::TextField, 'input', :type => 'text') do |how, what| @browser.find_element(how, what).clear @browser.find_element(how, what).send_keys(value) end end |
#text_fields_for(identifier) ⇒ Object
platform method to retrieve all text field elements
218 219 220 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 218 def text_fields_for(identifier) find_selenium_elements(identifier, Elements::TextField, 'input', :type => 'text') end |
#title ⇒ Object
platform method to retrieve the title for the current page See PageObject#title
55 56 57 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 55 def title @browser.title end |
#uncheck_checkbox(identifier) ⇒ Object
platform method to uncheck a checkbox See PageObject::Accessors#checkbox
358 359 360 361 362 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 358 def uncheck_checkbox(identifier) process_selenium_call(identifier, Elements::CheckBox, 'input', :type => 'checkbox') do |how, what| @browser.find_element(how, what).click if @browser.find_element(how, what).selected? end end |
#unordered_list_for(identifier) ⇒ Object
platform method to retrieve an unordered list element See PageObject::Accessors#unordered_list
608 609 610 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 608 def unordered_list_for(identifier) find_selenium_element(identifier, Elements::UnorderedList, 'ul') end |
#unordered_lists_for(identifier) ⇒ Object
platform method to retrieve all unordered lists
615 616 617 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 615 def unordered_lists_for(identifier) find_selenium_elements(identifier, Elements::UnorderedList, 'ul') end |
#wait_until(timeout, message = nil, &block) ⇒ Object
platform method to wait for a block to return true See PageObject#wait_until
63 64 65 66 |
# File 'lib/page-object/platforms/selenium_webdriver/page_object.rb', line 63 def wait_until(timeout, = nil, &block) wait = ::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => }) wait.until &block end |