Module: Druid::Accessors
- Defined in:
- lib/druid/accessors.rb
Overview
Contains the class level methods that are inserted into your page class when you include the PageObject module. These methods will generate another set of methods that provide access to the elements on the web pages.
Instance Method Summary collapse
-
#button(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to click a button, another to return the button element, and another to check the button’s existence.
-
#cell(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text from a table cell, another to return the table cell element, and another to check the cell’s existence.
-
#checkbox(name, identifier = {:index => 0}, &block) ⇒ Object
adds five methods - one to check, another to uncheck, another to return the state of a checkbox, another to return a PageObject::Elements::CheckBox object representing the checkbox, and a final method to check the checkbox’s existence.
-
#div(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text from a div, another to return the div element, and another to check the div’s existence.
-
#element(name, tag, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text an element, another to retrieve an element, and another to check the element’s existence.
-
#expected_element(element_name, timeout = 5) ⇒ boolean
Creates a method that provides a way to initialize a page based upon an expected element This is useful for pages that load dynamic content.
-
#expected_title(expected_title) ⇒ Boolean
Creates a method that compares the expected_title of a page against the actual.
-
#file_field(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to set the file for a file field, another to retrieve the file field element, and another to check it’s existence.
-
#form(name, identifier = {:index => 0}, &block) ⇒ Object
adds two methods - one to retrieve the form element, and another to check the form’s existence.
-
#h1(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text of a h1 element, another to retrieve a h1 element, and another to check for it’s existence.
-
#h2(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text of a h2 element, another to retrieve a h2 element, and another to check for it’s existence.
-
#h3(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text of a h3 element, another to return a h3 element, and another to check for it’s existence.
-
#h4(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text of a h4 element, another to return a h4 element, and another to check for it’s existence.
-
#h5(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text of a h5 element, another to return a h5 element, and another to check for it’s existence.
-
#h6(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text of a h6 element, another to return a h6 element, and another to check for it’s existence.
-
#hidden_field(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods to the page object - one to get the text from a hidden field, another to retrieve the hidden field element, and another to check the hidden field’s existence.
-
#image(name, identifier = {:index => 0}, &block) ⇒ Object
adds two methods - one to retrieve the image element, and another to check the image’s existence.
-
#in_frame(identifier, frame = nil, &block) ⇒ Object
Identify an element as existing within a frame or iframe.
-
#in_iframe(identifier, frame = nil, &block) ⇒ Object
Identify an element as existing within a frame or iframe.
-
#label(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text from a label, another to return the label element, and another to check the label’s existence.
-
#link(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to select a link, another to return a PageObject::Elements::Link object representing the link, and another that checks the link’s existence.
-
#list_item(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text from a list item, another to return the list item element, and another to check the list item’s existence.
-
#ordered_list(name, identifier = {:index => 0}, &block) ⇒ Object
adds two methods - one to retrieve the ordered list element, and another to test it’s existence.
-
#page_url(url) ⇒ Object
(also: #direct_url)
Specify the url for the page.
-
#paragraph(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text of a paragraph, another to retrieve a paragraph element, and another to check the paragraph’s existence.
-
#radio_button(name, identifier = {:index => 0}, &block) ⇒ Object
adds five methods - one to select, another to clear, another to return if a radio button is selected, another method to return a PageObject::Elements::RadioButton object representing the radio button element, and another to check the radio button’s existence.
-
#select_list(name, identifier = {:index => 0}, &block) ⇒ Object
adds four methods - one to select an item in a drop-down, another to fetch the currently selected item text, another to retrieve the select list element, and another to check the drop down’s existence.
-
#span(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text from a span, another to return the span element, and another to check the span’s existence.
-
#table(name, identifier = {:index => 0}, &block) ⇒ Object
adds two methods - one to retrieve the table element, and another to check the table’s existence.
-
#text_area(name, identifier = {:index => 0}, &block) ⇒ Object
adds four methods to the page object - one to set text in a text area, another to retrieve text from a text area, another to return the text area element, and another to check the text area’s existence.
-
#text_field(name, identifier = {:index => 0}, &block) ⇒ Object
adds four methods to the page objec - one to set text in a text field, another to retrieve text from a text field, another to return the text field element, another to check the text field’s existence.
-
#unordered_list(name, identifier = {:index => 0}, &block) ⇒ Object
adds two methods - one to retrieve the unordered list element, and another to check it’s existence.
Instance Method Details
#button(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to click a button, another to return the button element, and another to check the button’s existence.
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
# File 'lib/druid/accessors.rb', line 350 def (name, identifier={:index => 0}, &block) define_method(name) do return identifier.clone unless block_given? self.send("#{name}_element").click end define_method("#{name}_element") do return call_block(&block) if block_given? (identifier.clone) # block ? call_block(&block) : button_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? (identifier.clone).exist? end alias_method "#{name}_button".to_sym, "#{name}_element".to_sym end |
#cell(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text from a table cell, another to return the table cell element, and another to check the cell’s existence.
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 |
# File 'lib/druid/accessors.rb', line 456 def cell(name, identifier={:index => 0}, &block) define_method(name) do return cell_text_for identifier.clone unless block_given? self.send("#{name}_element").text end define_method("#{name}_element") do return call_block(&block) if block_given? cell_for(identifier.clone) # block ? call_block(&block) : cell_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? cell_for(identifier.clone).exist? end alias_method "#{name}_cell".to_sym, "#{name}_element".to_sym end |
#checkbox(name, identifier = {:index => 0}, &block) ⇒ Object
adds five methods - one to check, another to uncheck, another to return the state of a checkbox, another to return a PageObject::Elements::CheckBox object representing the checkbox, and a final method to check the checkbox’s existence.
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/druid/accessors.rb', line 214 def checkbox(name, identifier={:index => 0}, &block) define_method("check_#{name}") do return check_checkbox identifier.clone unless block_given? self.send("#{name}_element").check end define_method("uncheck_#{name}") do return uncheck_checkbox identifier.clone unless block_given? self.send("#{name}_element").uncheck end define_method("#{name}_checked?") do return checkbox_checked? identifier.clone unless block_given? self.send("#{name}_element").checked? end define_method("#{name}_element") do return call_block(&block) if block_given? checkbox_for(identifier.clone) # block ? call_block(&block) : checkbox_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? checkbox_for(identifier.clone).exist? end alias_method "#{name}_checkbox".to_sym, "#{name}_element".to_sym end |
#div(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text from a div, another to return the div element, and another to check the div’s existence.
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
# File 'lib/druid/accessors.rb', line 388 def div(name, identifier={:index => 0}, &block) define_method(name) do return div_text_for identifier.clone unless block_given? self.send("#{name}_element").text end define_method("#{name}_element") do return call_block(&block) if block_given? div_for(identifier.clone) # block ? call_block(&block) : div_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? div_for(identifier.clone).exist? end alias_method "#{name}_div".to_sym, "#{name}_element".to_sym end |
#element(name, tag, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text an element, another to retrieve an element, and another to check the element’s existence.
by combining of any of the following except xpath. The valid keys are:
* :class
* :id
* :index
* :name
* :xpath
1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 |
# File 'lib/druid/accessors.rb', line 1075 def element(name, tag, identifier={:index => 0}, &block) define_method("#{name}") do self.send("#{name}_element").text end define_method("#{name}_element") do return call_block(&block) if block_given? element_for(tag, identifier.clone) end define_method("#{name}?") do self.send("#{name}_element").exist? end end |
#expected_element(element_name, timeout = 5) ⇒ boolean
Creates a method that provides a way to initialize a page based upon an expected element This is useful for pages that load dynamic content
55 56 57 58 59 |
# File 'lib/druid/accessors.rb', line 55 def expected_element(element_name, timeout=5) define_method("has_expected_element?") do self.respond_to? "#{element_name}_element" and self.send("#{element_name}_element").when_present timeout end end |
#expected_title(expected_title) ⇒ Boolean
Creates a method that compares the expected_title of a page against the actual.
36 37 38 39 40 41 42 |
# File 'lib/druid/accessors.rb', line 36 def expected_title(expected_title) define_method("has_expected_title?") do has_expected_title = expected_title === title raise "Expected title '#{expected_title}' instead of '#{title}'" unless has_expected_title has_expected_title end end |
#file_field(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to set the file for a file field, another to retrieve the file field element, and another to check it’s existence.
1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 |
# File 'lib/druid/accessors.rb', line 1007 def file_field(name, identifier={:index => 0}, &block) define_method("#{name}=") do |value| return file_field_value_set(identifier.clone, value) unless block_given? self.send("#{name}_element").value = value end define_method("#{name}_element") do return call_block(&block) if block_given? file_field_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? file_field_for(identifier.clone).exist? end end |
#form(name, identifier = {:index => 0}, &block) ⇒ Object
adds two methods - one to retrieve the form element, and another to check the form’s existence.
561 562 563 564 565 566 567 568 569 570 571 572 |
# File 'lib/druid/accessors.rb', line 561 def form(name, identifier={:index => 0}, &block) define_method("#{name}_element") do return call_block(&block) if block_given? form_for(identifier.clone) # block ? call_block(&block) : form_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? form_for(identifier.clone).exist? end alias_method "#{name}_form".to_sym, "#{name}_element".to_sym end |
#h1(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text of a h1 element, another to retrieve a h1 element, and another to check for it’s existence.
768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 |
# File 'lib/druid/accessors.rb', line 768 def h1(name, identifier={:index => 0}, &block) define_method(name) do return h1_text_for identifier.clone unless block_given? self.send("#{name}_element").text end define_method("#{name}_element") do return call_block(&block) if block_given? h1_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? h1_for(identifier.clone).exist? end alias_method "#{name}_h1".to_sym, "#{name}_element".to_sym end |
#h2(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text of a h2 element, another to retrieve a h2 element, and another to check for it’s existence.
802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 |
# File 'lib/druid/accessors.rb', line 802 def h2(name, identifier={:index => 0}, &block) define_method(name) do return h2_text_for identifier.clone unless block_given? self.send("#{name}_element").text end define_method("#{name}_element") do return call_block(&block) if block_given? h2_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? h2_for(identifier.clone).exist? end alias_method "#{name}_h2".to_sym, "#{name}_element".to_sym end |
#h3(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text of a h3 element, another to return a h3 element, and another to check for it’s existence.
836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 |
# File 'lib/druid/accessors.rb', line 836 def h3(name, identifier={:index => 0}, &block) define_method(name) do return h3_text_for identifier.clone unless block_given? self.send("#{name}_element").text end define_method("#{name}_element") do return call_block(&block) if block_given? h3_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? h3_for(identifier.clone).exist? end alias_method "#{name}_h3".to_sym, "#{name}_element".to_sym end |
#h4(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text of a h4 element, another to return a h4 element, and another to check for it’s existence.
870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 |
# File 'lib/druid/accessors.rb', line 870 def h4(name, identifier={:index => 0}, &block) define_method(name) do return h4_text_for identifier.clone unless block_given? self.send("#{name}_element").text end define_method("#{name}_element") do return call_block(&block) if block_given? h4_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? h4_for(identifier.clone).exist? end alias_method "#{name}_h4".to_sym, "#{name}_element".to_sym end |
#h5(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text of a h5 element, another to return a h5 element, and another to check for it’s existence.
904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 |
# File 'lib/druid/accessors.rb', line 904 def h5(name, identifier={:index => 0}, &block) define_method(name) do return h5_text_for identifier.clone unless block_given? self.send("#{name}_element").text end define_method("#{name}_element") do return call_block(&block) if block_given? h5_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? h5_for(identifier.clone).exist? end alias_method "#{name}_h5".to_sym, "#{name}_element".to_sym end |
#h6(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text of a h6 element, another to return a h6 element, and another to check for it’s existence.
938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 |
# File 'lib/druid/accessors.rb', line 938 def h6(name, identifier={:index => 0}, &block) define_method(name) do return h6_text_for identifier.clone unless block_given? self.send("#{name}_element").text end define_method("#{name}_element") do return call_block(&block) if block_given? h6_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? h6_for(identifier.clone).exist? end alias_method "#{name}_h6".to_sym, "#{name}_element".to_sym end |
#hidden_field(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods to the page object - one to get the text from a hidden field, another to retrieve the hidden field element, and another to check the hidden field’s existence.
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 |
# File 'lib/druid/accessors.rb', line 595 def hidden_field(name, identifier={:index => 0}, &block) define_method("#{name}_element") do return call_block(&block) if block_given? hidden_field_for(identifier.clone) # block ? call_block(&block) : hidden_field_for(identifier.clone) end define_method(name) do return hidden_field_value_for identifier.clone unless block_given? self.send("#{name}_element").value end define_method("#{name}?") do return call_block(&block) if block_given? hidden_field_for(identifier.clone).exist? end alias_method "#{name}_hidden_field".to_sym, "#{name}_element".to_sym end |
#image(name, identifier = {:index => 0}, &block) ⇒ Object
adds two methods - one to retrieve the image element, and another to check the image’s existence.
529 530 531 532 533 534 535 536 537 538 539 540 |
# File 'lib/druid/accessors.rb', line 529 def image(name, identifier={:index => 0}, &block) define_method("#{name}_element") do return call_block(&block) if block_given? image_for(identifier.clone) # block ? call_block(&block) : image_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? image_for(identifier.clone).exist? end alias_method "#{name}_image".to_sym, "#{name}_element".to_sym end |
#in_frame(identifier, frame = nil, &block) ⇒ Object
Identify an element as existing within a frame or iframe. A frame parameter is passed to the block and must be passed to the other calls to Druid. You can nest calls to in_frame by passing the frame to the next level.
78 79 80 81 82 |
# File 'lib/druid/accessors.rb', line 78 def in_frame(identifier, frame=nil, &block) frame = [] if frame.nil? frame << {frame: identifier} block.call(frame) end |
#in_iframe(identifier, frame = nil, &block) ⇒ Object
Identify an element as existing within a frame or iframe. A frame parameter is passed to the block and must be passed to the other calls to Druid. You can nest calls to in_iframe by passing the frame to the next level.
100 101 102 103 104 |
# File 'lib/druid/accessors.rb', line 100 def in_iframe(identifier, frame=nil, &block) frame = [] if frame.nil? frame << {iframe: identifier} block.call(frame) end |
#label(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text from a label, another to return the label element, and another to check the label’s existence.
1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 |
# File 'lib/druid/accessors.rb', line 1041 def label(name, identifier={:index => 0}, &block) define_method(name) do return label_text_for identifier.clone unless block_given? self.send("#{name}_element").text end define_method("#{name}_element") do return call_block(&block) if block_given? label_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? label_for(identifier.clone).exist? end alias_method "#{name}_label".to_sym, "#{name}_element".to_sym end |
#link(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to select a link, another to return a PageObject::Elements::Link object representing the link, and another that checks the link’s existence.
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/druid/accessors.rb', line 131 def link(name, identifier={:index => 0}, &block) define_method(name) do return click_link_for identifier.clone unless block_given? self.send("#{name}_element").click end define_method("#{name}_element") do return call_block(&block) if block_given? link_for(identifier.clone) # block ? call_block(&block) : link_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? link_for(identifier.clone).exist? end alias_method "#{name}_link".to_sym, "#{name}_element".to_sym end |
#list_item(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text from a list item, another to return the list item element, and another to check the list item’s existence.
631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 |
# File 'lib/druid/accessors.rb', line 631 def list_item(name, identifier={:index => 0}, &block) define_method(name) do return list_item_text_for identifier.clone unless block_given? self.send("#{name}_element").text end define_method("#{name}_element") do return call_block(&block) if block_given? list_item_for(identifier.clone) # block ? call_block(&block) : list_item_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? list_item_for(identifier.clone).exist? end alias_method "#{name}_list_item".to_sym, "#{name}_element".to_sym end |
#ordered_list(name, identifier = {:index => 0}, &block) ⇒ Object
adds two methods - one to retrieve the ordered list element, and another to test it’s existence.
666 667 668 669 670 671 672 673 674 675 676 677 |
# File 'lib/druid/accessors.rb', line 666 def ordered_list(name, identifier={:index => 0}, &block) define_method("#{name}_element") do return call_block(&block) if block_given? ordered_list_for(identifier.clone) # block ? call_block(&block) : ordered_list_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? ordered_list_for(identifier.clone).exist? end alias_method "#{name}_ordered_list".to_sym, "#{name}_element".to_sym end |
#page_url(url) ⇒ Object Also known as: direct_url
Specify the url for the page. A call to this method will generate a ‘goto’ method to take you to the page.
17 18 19 20 21 22 |
# File 'lib/druid/accessors.rb', line 17 def page_url(url) define_method("goto") do url = url.kind_of?(Symbol) ? self.send(url) : url driver.goto url end end |
#paragraph(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text of a paragraph, another to retrieve a paragraph element, and another to check the paragraph’s existence.
972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 |
# File 'lib/druid/accessors.rb', line 972 def paragraph(name, identifier={:index => 0}, &block) define_method(name) do return paragraph_text_for identifier.clone unless block_given? self.send("#{name}_element").text end define_method("#{name}_element") do return call_block(&block) if block_given? paragraph_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? paragraph_for(identifier.clone).exist? end alias_method "#{name}_paragraph".to_sym, "#{name}_element".to_sym end |
#radio_button(name, identifier = {:index => 0}, &block) ⇒ Object
adds five methods - one to select, another to clear, another to return if a radio button is selected, another method to return a PageObject::Elements::RadioButton object representing the radio button element, and another to check the radio button’s existence.
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
# File 'lib/druid/accessors.rb', line 303 def (name, identifier={:index => 0}, &block) define_method("select_#{name}") do return select_radio identifier.clone unless block_given? self.send("#{name}_element").select end define_method("clear_#{name}") do return clear_radio identifier.clone unless block_given? self.send("#{name}_element").clear end define_method("#{name}_selected?") do return radio_selected? identifier.clone unless block_given? self.send("#{name}_element").selected? end define_method("#{name}_element") do return call_block(&block) if block_given? (identifier.clone) # block ? call_block(&block) : radio_button_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? (identifier.clone).exist? end alias_method "#{name}_radio_button".to_sym, "#{name}_element".to_sym end |
#select_list(name, identifier = {:index => 0}, &block) ⇒ Object
adds four methods - one to select an item in a drop-down, another to fetch the currently selected item text, another to retrieve the select list element, and another to check the drop down’s existence.
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
# File 'lib/druid/accessors.rb', line 259 def select_list(name, identifier={:index => 0}, &block) define_method(name) do return select_list_value_for identifier.clone unless block_given? self.send("#{name}_element")..each {|o| return o.text if o.selected?} end define_method("#{name}=") do |value| return select_list_value_set(identifier.clone, value) unless block_given? self.send("#{name}_element").select(value) end define_method("#{name}_element") do return call_block(&block) if block_given? select_list_for(identifier.clone) # block ? call_block(&block) : select_list_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? select_list_for(identifier.clone).exist? end alias_method "#{name}_select_list".to_sym, "#{name}_element".to_sym end |
#span(name, identifier = {:index => 0}, &block) ⇒ Object
adds three methods - one to retrieve the text from a span, another to return the span element, and another to check the span’s existence.
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
# File 'lib/druid/accessors.rb', line 492 def span(name, identifier={:index => 0}, &block) define_method(name) do return span_text_for identifier.clone unless block_given? self.send("#{name}_element").text end define_method("#{name}_element") do return call_block(&block) if block_given? span_for(identifier.clone) # block ? call_block(&block) : span_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? span_for(identifier.clone).exist? end alias_method "#{name}_span".to_sym, "#{name}_element".to_sym end |
#table(name, identifier = {:index => 0}, &block) ⇒ Object
adds two methods - one to retrieve the table element, and another to check the table’s existence.
423 424 425 426 427 428 429 430 431 432 433 434 |
# File 'lib/druid/accessors.rb', line 423 def table(name, identifier={:index => 0}, &block) define_method("#{name}_element") do return call_block(&block) if block_given? table_for(identifier.clone) # block ? call_block(&block) : table_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? table_for(identifier.clone).exist? end alias_method "#{name}_table".to_sym, "#{name}_element".to_sym end |
#text_area(name, identifier = {:index => 0}, &block) ⇒ Object
adds four methods to the page object - one to set text in a text area, another to retrieve text from a text area, another to return the text area element, and another to check the text area’s existence.
699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 |
# File 'lib/druid/accessors.rb', line 699 def text_area(name, identifier={:index => 0}, &block) define_method("#{name}=") do |value| return text_area_value_set(identifier.clone, value) unless block_given? self.send("#{name}_element").value = value end define_method(name) do return text_area_value_for identifier.clone unless block_given? self.send("#{name}_element").value end define_method("#{name}_element") do return call_block(&block) if block_given? text_area_for(identifier.clone) # block ? call_block(&block) : text_area_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? text_area_for(identifier.clone).exist? end alias_method "#{name}_text_area".to_sym, "#{name}_element".to_sym end |
#text_field(name, identifier = {:index => 0}, &block) ⇒ Object
adds four methods to the page objec - one to set text in a text field, another to retrieve text from a text field, another to return the text field element, another to check the text field’s existence.
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/druid/accessors.rb', line 171 def text_field(name, identifier={:index => 0}, &block) define_method(name) do return text_field_value_for identifier.clone unless block_given? self.send("#{name}_element").value end define_method("#{name}=") do |value| return text_field_value_set(identifier.clone, value) unless block_given? self.send("#{name}_element").value = value end define_method("#{name}_element") do return call_block(&block) if block_given? text_field_for(identifier.clone) # block ? call_block(&block) : text_field_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? text_field_for(identifier.clone).exist? end alias_method "#{name}_text_field".to_sym, "#{name}_element".to_sym end |
#unordered_list(name, identifier = {:index => 0}, &block) ⇒ Object
adds two methods - one to retrieve the unordered list element, and another to check it’s existence.
737 738 739 740 741 742 743 744 745 746 747 748 |
# File 'lib/druid/accessors.rb', line 737 def unordered_list(name, identifier={:index => 0}, &block) define_method("#{name}_element") do return call_block(&block) if block_given? unordered_list_for(identifier.clone) # block ? call_block(&block) : unordered_list_for(identifier.clone) end define_method("#{name}?") do return call_block(&block) if block_given? unordered_list_for(identifier.clone).exist? end alias_method "#{name}_unordered_list".to_sym, "#{name}_element".to_sym end |