lib/prickle/capybara/match.rb in prickle-0.0.1 vs lib/prickle/capybara/match.rb in prickle-0.0.2
- old
+ new
@@ -2,30 +2,32 @@
module Actions
module Match
def contains_text? text
handle_exception do
- find_element_by_name_and_text(@type, @identifier, text)
+ find_element_by_identifier_and_text
end
end
- def method_missing method, *args
- if method =~ /(^.*)_contains_text\?$/
- find_element_by_name_and_text($1, { :name => args.first } , args[1])
- else
- super
- end
+ private
+
+ def xpath_for_identifier
+ "//#{type_of(@type)}[#{identifier}]"
end
- private
+ def xpath_for_identifier_and_text
+ "//#{type_of(@type)}[#{identifier} and contains(text(), '#{@text}')]"
- def find_by_name_and_text_xpath element, identifier, text
- "//#{type_of(element)}[#{xpath_for(identifier)} and contains(text(), '#{text}')]"
end
+ def find_element_by_identifier
+ handle_exception do
+ find_element_by xpath_for_identifier
+ end
+ end
- def find_element_by_name_and_text element, name, text
+ def find_element_by_identifier_and_text
handle_exception do
- find_element_by(find_by_name_and_text_xpath(element, name, text))
+ find_element_by xpath_for_identifier_and_text
end
end
end
end