Skip to content

Commit

Permalink
Adding have_xpath matcher for Selenium
Browse files Browse the repository at this point in the history
  • Loading branch information
brynary committed Dec 3, 2008
1 parent 0888c68 commit 881d9f3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/webrat/selenium/matchers.rb
Expand Up @@ -2,6 +2,34 @@ module Webrat
module Selenium
module Matchers

class HaveXpath
def initialize(expected)
@expected = expected
end

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

# ==== Returns
# String:: The failure message.
def failure_message
"expected following text to match xpath #{@expected}:\n#{@document}"
end

# ==== Returns
# String:: The failure message to be displayed in negative matches.
def negative_failure_message
"expected following text to not match xpath #{@expected}:\n#{@document}"
end
end

def have_xpath(xpath)
HaveXpath.new(xpath)
end

class HaveSelector
def initialize(expected)
@expected = expected
Expand Down

0 comments on commit 881d9f3

Please sign in to comment.