Skip to content

Commit

Permalink
don't pass xpath around
Browse files Browse the repository at this point in the history
  • Loading branch information
despo committed Feb 11, 2012
1 parent 0020a6c commit 31fef60
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions lib/prickle/capybara/element.rb
Expand Up @@ -21,11 +21,25 @@ def initialize type=OF_ANY_TYPE, identifier
self
end

def identifier
return @identifier.each_pair.to_a.map { |k, v| "@#{k}='#{v}'" }.join " and "
end

def type
CONVERTED_TYPES[@type.to_sym] || @type
end

def find_element
handle_exception { find_element_by xpath }
handle_exception { find_element_by_xpath }
end

def xpath
xpath = "//#{type}[#{identifier}"
xpath << " and contains(text(), '#{@text}')" if @text
xpath << "]"
end

def find_element_by xpath
def find_element_by_xpath
wait_until(Prickle::Capybara.wait_time) do
find(:xpath, xpath).visible?
end unless Prickle::Capybara.wait_time.nil?
Expand All @@ -43,20 +57,6 @@ def handle_exception &block
end
end

def identifier
return @identifier.each_pair.to_a.map { |k, v| "@#{k}='#{v}'" }.join " and "
end

def type
CONVERTED_TYPES[@type.to_sym] || @type
end

def xpath
xpath = "//#{type}[#{identifier}"
xpath << " and contains(text(), '#{@text}')" if @text
xpath << "]"
end

public

include Prickle::Capybara::Actions
Expand Down

0 comments on commit 31fef60

Please sign in to comment.