lib/capybara/spec/session/element/match_xpath_spec.rb
# 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
Source Files
- lib/capybara.rb
- lib/capybara/config.rb
- lib/capybara/cucumber.rb
- lib/capybara/driver/base.rb
- lib/capybara/driver/node.rb
- lib/capybara/dsl.rb
- lib/capybara/helpers.rb
- lib/capybara/minitest.rb
- lib/capybara/minitest/spec.rb
- lib/capybara/node/actions.rb
- lib/capybara/node/base.rb
- lib/capybara/node/document.rb
- lib/capybara/node/document_matchers.rb
- lib/capybara/node/element.rb
- lib/capybara/node/finders.rb
- lib/capybara/node/matchers.rb
- lib/capybara/node/simple.rb
- lib/capybara/queries/ancestor_query.rb
- lib/capybara/queries/base_query.rb
- lib/capybara/queries/current_path_query.rb
- lib/capybara/queries/match_query.rb
- lib/capybara/queries/selector_query.rb
- lib/capybara/queries/sibling_query.rb
- lib/capybara/queries/style_query.rb
- lib/capybara/queries/text_query.rb
- lib/capybara/queries/title_query.rb
- lib/capybara/rack_test/browser.rb
- lib/capybara/rack_test/css_handlers.rb
- lib/capybara/rack_test/driver.rb
- lib/capybara/rack_test/form.rb
- lib/capybara/rack_test/node.rb
- lib/capybara/rails.rb
- lib/capybara/result.rb
- lib/capybara/rspec.rb
- lib/capybara/rspec/compound.rb
- lib/capybara/rspec/features.rb
- lib/capybara/rspec/matcher_proxies.rb
- lib/capybara/rspec/matchers.rb
- lib/capybara/selector.rb
- lib/capybara/selector/builders/css_builder.rb
- lib/capybara/selector/builders/xpath_builder.rb
- lib/capybara/selector/css.rb
- lib/capybara/selector/filter.rb
- lib/capybara/selector/filter_set.rb
- lib/capybara/selector/filters/base.rb
- lib/capybara/selector/filters/expression_filter.rb
- lib/capybara/selector/filters/node_filter.rb
- lib/capybara/selector/regexp_disassembler.rb
- lib/capybara/selector/selector.rb
- lib/capybara/selenium/driver.rb
- lib/capybara/selenium/driver_specializations/chrome_driver.rb
- lib/capybara/selenium/driver_specializations/marionette_driver.rb
- lib/capybara/selenium/extensions/html5_drag.rb
- lib/capybara/selenium/node.rb
- lib/capybara/selenium/nodes/chrome_node.rb
- lib/capybara/selenium/nodes/marionette_node.rb
- lib/capybara/selenium/patches/pause_duration_fix.rb
- lib/capybara/server.rb
- lib/capybara/server/animation_disabler.rb
- lib/capybara/server/checker.rb
- lib/capybara/server/middleware.rb
- lib/capybara/session.rb
- lib/capybara/session/config.rb
- lib/capybara/session/matchers.rb
- lib/capybara/spec/session/accept_alert_spec.rb
- lib/capybara/spec/session/accept_confirm_spec.rb
- lib/capybara/spec/session/accept_prompt_spec.rb
- lib/capybara/spec/session/all_spec.rb
- lib/capybara/spec/session/ancestor_spec.rb
- lib/capybara/spec/session/assert_all_of_selectors_spec.rb
- lib/capybara/spec/session/assert_current_path_spec.rb
- lib/capybara/spec/session/assert_selector_spec.rb
- lib/capybara/spec/session/assert_style_spec.rb
- lib/capybara/spec/session/assert_text_spec.rb
- lib/capybara/spec/session/assert_title_spec.rb
- lib/capybara/spec/session/attach_file_spec.rb
- lib/capybara/spec/session/body_spec.rb
- lib/capybara/spec/session/check_spec.rb
- lib/capybara/spec/session/choose_spec.rb
- lib/capybara/spec/session/click_button_spec.rb
- lib/capybara/spec/session/click_link_or_button_spec.rb
- lib/capybara/spec/session/click_link_spec.rb
- lib/capybara/spec/session/current_scope_spec.rb
- lib/capybara/spec/session/current_url_spec.rb
- lib/capybara/spec/session/dismiss_confirm_spec.rb
- lib/capybara/spec/session/dismiss_prompt_spec.rb
- lib/capybara/spec/session/element/assert_match_selector_spec.rb
- lib/capybara/spec/session/element/match_css_spec.rb
- lib/capybara/spec/session/element/match_xpath_spec.rb
- lib/capybara/spec/session/element/matches_selector_spec.rb
- lib/capybara/spec/session/evaluate_async_script_spec.rb
- lib/capybara/spec/session/evaluate_script_spec.rb
- lib/capybara/spec/session/execute_script_spec.rb
- lib/capybara/spec/session/fill_in_spec.rb
- lib/capybara/spec/session/find_button_spec.rb
- lib/capybara/spec/session/find_by_id_spec.rb
- lib/capybara/spec/session/find_field_spec.rb
- lib/capybara/spec/session/find_link_spec.rb
- lib/capybara/spec/session/find_spec.rb
- lib/capybara/spec/session/first_spec.rb
- lib/capybara/spec/session/frame/frame_title_spec.rb
- lib/capybara/spec/session/frame/frame_url_spec.rb
- lib/capybara/spec/session/frame/switch_to_frame_spec.rb
- lib/capybara/spec/session/frame/within_frame_spec.rb
- lib/capybara/spec/session/go_back_spec.rb
- lib/capybara/spec/session/go_forward_spec.rb
- lib/capybara/spec/session/has_all_selectors_spec.rb
- lib/capybara/spec/session/has_button_spec.rb
- lib/capybara/spec/session/has_css_spec.rb
- lib/capybara/spec/session/has_current_path_spec.rb
- lib/capybara/spec/session/has_field_spec.rb
- lib/capybara/spec/session/has_link_spec.rb
- lib/capybara/spec/session/has_none_selectors_spec.rb
- lib/capybara/spec/session/has_select_spec.rb
- lib/capybara/spec/session/has_selector_spec.rb
- lib/capybara/spec/session/has_style_spec.rb
- lib/capybara/spec/session/has_table_spec.rb
- lib/capybara/spec/session/has_text_spec.rb
- lib/capybara/spec/session/has_title_spec.rb
- lib/capybara/spec/session/has_xpath_spec.rb
- lib/capybara/spec/session/headers_spec.rb
- lib/capybara/spec/session/html_spec.rb
- lib/capybara/spec/session/node_spec.rb
- lib/capybara/spec/session/node_wrapper_spec.rb
- lib/capybara/spec/session/refresh_spec.rb
- lib/capybara/spec/session/reset_session_spec.rb
- lib/capybara/spec/session/response_code_spec.rb
- lib/capybara/spec/session/save_and_open_page_spec.rb
- lib/capybara/spec/session/save_and_open_screenshot_spec.rb
- lib/capybara/spec/session/save_page_spec.rb
- lib/capybara/spec/session/save_screenshot_spec.rb
- lib/capybara/spec/session/screenshot_spec.rb
- lib/capybara/spec/session/select_spec.rb
- lib/capybara/spec/session/selectors_spec.rb
- lib/capybara/spec/session/sibling_spec.rb
- lib/capybara/spec/session/source_spec.rb
- lib/capybara/spec/session/text_spec.rb
- lib/capybara/spec/session/title_spec.rb
- lib/capybara/spec/session/uncheck_spec.rb
- lib/capybara/spec/session/unselect_spec.rb
- lib/capybara/spec/session/visit_spec.rb
- lib/capybara/spec/session/window/become_closed_spec.rb
- lib/capybara/spec/session/window/current_window_spec.rb
- lib/capybara/spec/session/window/open_new_window_spec.rb
- lib/capybara/spec/session/window/switch_to_window_spec.rb
- lib/capybara/spec/session/window/window_opened_by_spec.rb
- lib/capybara/spec/session/window/window_spec.rb
- lib/capybara/spec/session/window/windows_spec.rb
- lib/capybara/spec/session/window/within_window_spec.rb
- lib/capybara/spec/session/within_spec.rb
- lib/capybara/spec/spec_helper.rb
- lib/capybara/spec/test_app.rb
- lib/capybara/version.rb
- lib/capybara/window.rb
- lib/capybara/xpath_patches.rb