Class: XPath::Expression::Father

Inherits:
Multiple
  • Object
show all
Defined in:
lib/capybara-js_finders/xpath_extensions.rb

Instance Method Summary collapse

Instance Method Details

#to_xpath(predicate = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/capybara-js_finders/xpath_extensions.rb', line 6

def to_xpath(predicate=nil)
  if @expressions.length == 1
    "#{@left.to_xpath(predicate)}/../self::#{@expressions.first.to_xpath(predicate)}"
  elsif @expressions.length > 1
    "#{@left.to_xpath(predicate)}/../self::*[#{@expressions.map { |e| "self::#{e.to_xpath(predicate)}" }.join(" | ")}]"
  else
    "#{@left.to_xpath(predicate)}/../self::*"
  end
end