Sha256: 76ac1d01a1c58db725408ab24917f1a748892adab42f502cbd4c82bf0d6e15a3

Contents?: true

Size: 845 Bytes

Versions: 97

Compression:

Stored size: 845 Bytes

Contents

# frozen_string_literal: true

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

97 entries across 83 versions & 5 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/capybara-3.40.0/lib/capybara/spec/session/element/match_xpath_spec.rb
capybara-3.40.0 lib/capybara/spec/session/element/match_xpath_spec.rb
capybara-3.39.2 lib/capybara/spec/session/element/match_xpath_spec.rb
capybara-3.39.1 lib/capybara/spec/session/element/match_xpath_spec.rb
capybara-3.39.0 lib/capybara/spec/session/element/match_xpath_spec.rb
tdiary-5.2.4 vendor/bundle/ruby/3.1.0/gems/capybara-3.36.0/lib/capybara/spec/session/element/match_xpath_spec.rb
capybara-3.38.0 lib/capybara/spec/session/element/match_xpath_spec.rb
tdiary-5.2.3 vendor/bundle/ruby/3.1.0/gems/capybara-3.37.1/lib/capybara/spec/session/element/match_xpath_spec.rb
tdiary-5.2.2 vendor/bundle/ruby/3.1.0/gems/capybara-3.37.1/lib/capybara/spec/session/element/match_xpath_spec.rb
capybara-3.37.1 lib/capybara/spec/session/element/match_xpath_spec.rb
capybara-3.37.0 lib/capybara/spec/session/element/match_xpath_spec.rb
tdiary-5.2.1 vendor/bundle/ruby/3.1.0/gems/capybara-3.36.0/lib/capybara/spec/session/element/match_xpath_spec.rb
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/capybara-3.36.0/lib/capybara/spec/session/element/match_xpath_spec.rb
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/capybara-3.35.3/lib/capybara/spec/session/element/match_xpath_spec.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/capybara-3.36.0/lib/capybara/spec/session/element/match_xpath_spec.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/capybara-3.36.0/lib/capybara/spec/session/element/match_xpath_spec.rb
capybara-3.36.0 lib/capybara/spec/session/element/match_xpath_spec.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/capybara-3.35.3/lib/capybara/spec/session/element/match_xpath_spec.rb
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/capybara-3.35.3/lib/capybara/spec/session/element/match_xpath_spec.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/capybara-3.35.3/lib/capybara/spec/session/element/match_xpath_spec.rb