1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

within_frame should allow no arguments when theres only one frame in scope

This commit is contained in:
Thomas Walpole 2018-07-06 08:56:40 -07:00
parent 5b76480e57
commit d3d57d7ff0
2 changed files with 18 additions and 0 deletions

View file

@ -397,6 +397,8 @@ module Capybara
scopes.slice!(idx..-1)
driver.switch_to_frame(:top)
end
else
raise ArgumentError, "You must provide a frame element, :parent, or :top when calling switch_to_frame"
end
end
@ -846,6 +848,8 @@ module Capybara
end
def _find_frame(*args)
return find(:frame) if args.length.zero?
case args[0]
when Capybara::Node::Element
args[0]

View file

@ -54,6 +54,20 @@ Capybara::SpecHelper.spec '#within_frame', requires: [:frames] do
end
end
it "should default to the :frame selector when no options passed" do
container = @session.find(:css, '#divInMainWindow')
@session.within(container) do
# Ensure only one frame in scope
@session.within_frame do
expect(@session).to have_css('body#parentBody')
end
end
expect {
# Multiple frames in scope here
@session.within_frame do; end
}.to raise_error Capybara::Ambiguous
end
it "should find multiple nested frames" do
@session.within_frame 'parentFrame' do
@session.within_frame 'childFrame' do