Sha256: 777cfe2d0a23d285a27b4a42675886ed9ed8ea807253bc5d2eac956c790ff65f

Contents?: true

Size: 1.16 KB

Versions: 61

Compression:

Stored size: 1.16 KB

Contents

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
          rescue Webrat::TimeoutError
            false
        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

      def assert_have_xpath(expected)
        hs = HaveXpath.new(expected)
        assert hs.matches?(response), hs.failure_message
      end

      def assert_have_no_xpath(expected)
        hs = HaveXpath.new(expected)
        assert !hs.matches?(response), hs.negative_failure_message
      end
    end
  end
end

Version data entries

61 entries across 61 versions & 26 rubygems

Version Path
aslakhellesoy-webrat-0.4.4.1 lib/webrat/selenium/matchers/have_xpath.rb
casebook-webrat-0.4.4.1 lib/webrat/selenium/matchers/have_xpath.rb
cavalle-webrat-0.4.4.1 lib/webrat/selenium/matchers/have_xpath.rb
cavalle-webrat-0.4.4.2 lib/webrat/selenium/matchers/have_xpath.rb
davidtrogers-webrat-0.4.4.2 lib/webrat/selenium/matchers/have_xpath.rb
dbrady-webrat-0.4.4.1 lib/webrat/selenium/matchers/have_xpath.rb
dbrady-webrat-0.4.4.2 lib/webrat/selenium/matchers/have_xpath.rb
dbrady-webrat-0.4.4 lib/webrat/selenium/matchers/have_xpath.rb
diabolo-diabolo-webrat-0.4.4 lib/webrat/selenium/matchers/have_xpath.rb
diabolo-webrat-0.4.3 lib/webrat/selenium/matchers/have_xpath.rb
diabolo-webrat-0.4.4.1 lib/webrat/selenium/matchers/have_xpath.rb
diabolo-webrat-0.4.4.2 lib/webrat/selenium/matchers/have_xpath.rb
diabolo-webrat-0.4.4 lib/webrat/selenium/matchers/have_xpath.rb
diabolo-webrat-0.5.1 lib/webrat/selenium/matchers/have_xpath.rb
dstrelau-webrat-0.5.1 lib/webrat/selenium/matchers/have_xpath.rb
emipair-webrat-0.0.1 lib/webrat/selenium/matchers/have_xpath.rb
futuresinc-webrat-0.4.4.100 lib/webrat/selenium/matchers/have_xpath.rb
futuresinc-webrat-0.4.4.99 lib/webrat/selenium/matchers/have_xpath.rb
garnierjm-webrat-0.4.5 lib/webrat/selenium/matchers/have_xpath.rb
hardbap-webrat-0.5.1 lib/webrat/selenium/matchers/have_xpath.rb