Sha256: 100905b052e3ab5f7d3fea2f123fc4224059bb56717d43bd54f372dbb890daff

Contents?: true

Size: 1.17 KB

Versions: 34

Compression:

Stored size: 1.17 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

34 entries across 34 versions & 8 rubygems

Version Path
adva-0.3.2 test/webrat/lib/webrat/selenium/matchers/have_xpath.rb
adva-0.3.1 test/webrat/lib/webrat/selenium/matchers/have_xpath.rb
adva-0.3.0 test/webrat/lib/webrat/selenium/matchers/have_xpath.rb
adva-0.2.4 test/webrat/lib/webrat/selenium/matchers/have_xpath.rb
adva-0.2.3 test/webrat/lib/webrat/selenium/matchers/have_xpath.rb
adva-0.2.2 test/webrat/lib/webrat/selenium/matchers/have_xpath.rb
adva-0.2.1 test/webrat/lib/webrat/selenium/matchers/have_xpath.rb
adva-0.2.0 test/webrat/lib/webrat/selenium/matchers/have_xpath.rb
adva-0.1.4 test/webrat/lib/webrat/selenium/matchers/have_xpath.rb
adva-0.1.3 test/webrat/lib/webrat/selenium/matchers/have_xpath.rb
adva-0.1.2 test/webrat/lib/webrat/selenium/matchers/have_xpath.rb
adva-0.1.1 test/webrat/lib/webrat/selenium/matchers/have_xpath.rb
adva-0.1.0 test/webrat/lib/webrat/selenium/matchers/have_xpath.rb
adva-0.0.1 test/webrat/lib/webrat/selenium/matchers/have_xpath.rb
diabolo-webrat-0.4.2 lib/webrat/selenium/matchers/have_xpath.rb
jferris-webrat-0.4.3.0.1238640835 lib/webrat/selenium/matchers/have_xpath.rb
jferris-webrat-0.4.3 lib/webrat/selenium/matchers/have_xpath.rb
jwilger-webrat-0.4.2.1 lib/webrat/selenium/matchers/have_xpath.rb
jwilger-webrat-0.4.2.2 lib/webrat/selenium/matchers/have_xpath.rb
jwilger-webrat-0.4.2.3 lib/webrat/selenium/matchers/have_xpath.rb