Method: PageObjectWrapper::PageObject#method_missing
- Defined in:
- lib/page_object_wrapper/PageObject.rb
#method_missing(method_name, *args, &block) ⇒ Object
lazy evaluated calls of real watir elements are handled by :method_missing
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/page_object_wrapper/PageObject.rb', line 51 def method_missing(method_name, *args, &block) case when KNOWN_ELEMENTS.include?(method_name.to_s.gsub(/^uniq_/,'')) # page_object.uniq_xxx(hash) meth = method_name.to_s.gsub(/^uniq_/,'') e = Element.new(method_name.to_sym, meth) e.instance_eval { locator(args[0]); required(true) } @elements << e when has_eset?(method_name) # page_object.some_elements_set eset = eset_for(method_name) PageObjectWrapper.current_result = PageObject.return_array_of_watir_elements(eset) when has_element?(method_name) # page_object.some_element element = element_for(method_name) PageObjectWrapper.current_result = PageObject.return_watir_element element when FEED_ALL.match(method_name) # page_object.feed_all(:fresh_food) PageObjectWrapper.current_result = feed_elements(@elements, *args) when (FEED.match(method_name) and has_eset?($1)) # page_object.feed_some_elements_set(:fresh_food) eset = eset_for($1) PageObjectWrapper.current_result = feed_elements(eset.elements, *args) when (FEED.match(method_name) and has_element?($1)) # page_object.feed_some_element(:fresh_food) e = element_for($1) if [true, false].include? args[0] or args[0].is_a? String PageObjectWrapper.current_result = feed_field(e, args[0]) else PageObjectWrapper.current_result = feed_elements([e], *args) end when (FIRE_ACTION.match(method_name) and has_action?($1)) # page_object.fire_some_action a = action_for($1) PageObjectWrapper.current_result = fire_action(a, *args) when (FIRE_ACTION.match(method_name) and has_alias?($1)) # page_object.fire_some_action a = alias_for($1) PageObjectWrapper.current_result = fire_action(a, *args) when (VALIDATE.match(method_name) and has_validator?($1)) # page_object.validate_something v = validator_for($1) PageObjectWrapper.current_result = run_validator(v, *args) when (SELECT_FROM.match(method_name) and has_table?($1)) # page_object.select_from_some_table(:header_column, {:column => 'value'}) table = table_for($1) PageObjectWrapper.current_result = select_from(table, *args) when (SELECT_ROW_FROM.match(method_name) and has_table?($1)) # page_object.select_row_from_some_table(:number => 1, :column1 => value1, :column2 => value3, ...) table = table_for($1) PageObjectWrapper.current_result = select_row_from(table, args[0]) when (PAGINATION_EACH.match(method_name) and has_pagination?($1)) # page_object.each_pagination pagination = pagination_for($1) PageObjectWrapper.current_result = run_each_subpage(pagination, *args, &block) when (PAGINATION_OPEN.match(method_name) and has_pagination?($1)) # page_object.open_padination(1) pagination = pagination_for($1) PageObjectWrapper.current_result = open_subpage(pagination, *args) when (PRESS.match(method_name) and has_element?($1)) # page_object.press_element element = element_for($1) PageObjectWrapper.current_result = press(element) else super end end |