Class: Webrat::Selenium::Matchers::HaveXpath

Inherits:
Object
  • Object
show all
Defined in:
lib/webrat/selenium/matchers/have_xpath.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ HaveXpath

Returns a new instance of HaveXpath.



5
6
7
# File 'lib/webrat/selenium/matchers/have_xpath.rb', line 5

def initialize(expected)
  @expected = expected
end

Instance Method Details

#failure_messageObject

Returns

String

The failure message.



19
20
21
# File 'lib/webrat/selenium/matchers/have_xpath.rb', line 19

def failure_message
  "expected following text to match xpath #{@expected}:\n#{@document}"
end

#matches?(response) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
# File 'lib/webrat/selenium/matchers/have_xpath.rb', line 9

def matches?(response)
  response.session.wait_for do
    response.selenium.is_element_present("xpath=#{@expected}")
  end
  rescue Webrat::TimeoutError
    false
end

#negative_failure_messageObject

Returns

String

The failure message to be displayed in negative matches.



25
26
27
# File 'lib/webrat/selenium/matchers/have_xpath.rb', line 25

def negative_failure_message
  "expected following text to not match xpath #{@expected}:\n#{@document}"
end