mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Default to document when element has no parent in match selector query
This commit is contained in:
parent
60c02517d6
commit
ef292c8e04
4 changed files with 15 additions and 2 deletions
|
@ -1,3 +1,10 @@
|
|||
# Version 3.7.2
|
||||
Release date: unreleased
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fix MatchQuery based matchers when used on a root element found using any type of parent/ancestor query - Issue #2097
|
||||
|
||||
# Version 3.7.1
|
||||
Release date: 2018-09-05
|
||||
|
||||
|
|
|
@ -713,7 +713,7 @@ module Capybara
|
|||
query_args = _set_query_session_options(*query_args)
|
||||
query = Capybara::Queries::MatchQuery.new(*query_args, &optional_filter_block)
|
||||
synchronize(query.wait) do
|
||||
yield query.resolve_for(first(:xpath, './parent::*', minimum: 0) || query_scope)
|
||||
yield query.resolve_for(first(:xpath, './parent::*', minimum: 0) || session&.document || query_scope)
|
||||
end
|
||||
true
|
||||
end
|
||||
|
|
|
@ -364,7 +364,7 @@ module Capybara
|
|||
# @overload switch_to_frame(element)
|
||||
# @param [Capybara::Node::Element] iframe/frame element to switch to
|
||||
# @overload switch_to_frame(:parent)
|
||||
# Switch to the parent element
|
||||
# Switch to the parent frame
|
||||
# @overload switch_to_frame(:top)
|
||||
# Switch to the top level document
|
||||
#
|
||||
|
|
|
@ -22,4 +22,10 @@ Capybara::SpecHelper.spec '#match_css?' do
|
|||
expect(@element).to match_css('span') { |el| el[:class] == 'number' }
|
||||
expect(@element).not_to match_css('span') { |el| el[:class] == 'not_number' }
|
||||
end
|
||||
|
||||
it 'should work with root element found via ancestor' do
|
||||
el = @session.find(:css, 'body').find(:xpath, '..')
|
||||
expect(el).to match_css('html')
|
||||
expect { expect(el).to not_match_css('html') }.to raise_exception(RSpec::Expectations::ExpectationNotMetError)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue