class Prickle::Capybara::Element
Constants
- CONVERTED_TYPES
- MISSING_METHOD_REGEX
- OF_ANY_TYPE
Public Class Methods
new(type=OF_ANY_TYPE, identifier)
click to toggle source
# File lib/prickle/capybara/element.rb, line 21 def initialize type=OF_ANY_TYPE, identifier @identifier = identifier @type = type self end
Private Class Methods
extract_method_missing(properties)
click to toggle source
# File lib/prickle/capybara/element.rb, line 64 def self.extract_method_missing properties element = { } element[:method] = properties[1] || properties[2] element[:args] = properties[4][1] element end
Private Instance Methods
element_not_found(caught_exception)
click to toggle source
# File lib/prickle/capybara/element.rb, line 60 def element_not_found caught_exception Exceptions::ElementNotFound.new(@type, identifier, @text, caught_exception) end
find_element()
click to toggle source
# File lib/prickle/capybara/element.rb, line 35 def find_element handle_exception { find_element_by_xpath } end
find_element_by_xpath()
click to toggle source
# File lib/prickle/capybara/element.rb, line 39 def find_element_by_xpath Timeout.timeout(Capybara.wait_time) do sleep(0.1) until find(:xpath, xpath).visible? end unless Capybara.wait_time.nil? find :xpath, xpath end
handle_exception(&block)
click to toggle source
# File lib/prickle/capybara/element.rb, line 51 def handle_exception &block begin block.call rescue Exception => e raise element_not_found(e) if e.class == ::Capybara::ElementNotFound raise end end
identifier()
click to toggle source
# File lib/prickle/capybara/element.rb, line 27 def identifier @identifier end
type_as_tag()
click to toggle source
# File lib/prickle/capybara/element.rb, line 31 def type_as_tag CONVERTED_TYPES[@type.to_sym] || @type end
xpath()
click to toggle source
# File lib/prickle/capybara/element.rb, line 47 def xpath XPath::for_element_with type_as_tag, identifier end