Sha256: 991dbdcdb375a1706c6c16a903091185ef0e802c32f80f81737f70f185be8d81

Contents?: true

Size: 814 Bytes

Versions: 6

Compression:

Stored size: 814 Bytes

Contents

Capybara::SpecHelper.spec '#match_xpath?' do
  before do
    @session.visit('/with_html')
    @element = @session.find(:css, 'span.number')
  end

  it "should be true if the given selector is on the page" do
    expect(@element).to match_xpath("//span")
    expect(@element).to match_xpath("//span[@class='number']")
  end

  it "should be false if the given selector is not on the page" do
    expect(@element).not_to match_xpath("//abbr")
    expect(@element).not_to match_xpath("//div")
    expect(@element).not_to match_xpath("//span[@class='not_a_number']")
  end

  it "should use xpath even if default selector is CSS" do
    Capybara.default_selector = :css
    expect(@element).not_to have_xpath("//span[@class='not_a_number']")
    expect(@element).not_to have_xpath("//div[@class='number']")
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
capybara-3.0.3 lib/capybara/spec/session/element/match_xpath_spec.rb
capybara-3.0.2 lib/capybara/spec/session/element/match_xpath_spec.rb
capybara-3.0.1 lib/capybara/spec/session/element/match_xpath_spec.rb
capybara-3.0.0 lib/capybara/spec/session/element/match_xpath_spec.rb
capybara-3.0.0.rc2 lib/capybara/spec/session/element/match_xpath_spec.rb
capybara-3.0.0.rc1 lib/capybara/spec/session/element/match_xpath_spec.rb