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:
parent
5b76480e57
commit
d3d57d7ff0
2 changed files with 18 additions and 0 deletions
|
@ -397,6 +397,8 @@ module Capybara
|
||||||
scopes.slice!(idx..-1)
|
scopes.slice!(idx..-1)
|
||||||
driver.switch_to_frame(:top)
|
driver.switch_to_frame(:top)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
raise ArgumentError, "You must provide a frame element, :parent, or :top when calling switch_to_frame"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -846,6 +848,8 @@ module Capybara
|
||||||
end
|
end
|
||||||
|
|
||||||
def _find_frame(*args)
|
def _find_frame(*args)
|
||||||
|
return find(:frame) if args.length.zero?
|
||||||
|
|
||||||
case args[0]
|
case args[0]
|
||||||
when Capybara::Node::Element
|
when Capybara::Node::Element
|
||||||
args[0]
|
args[0]
|
||||||
|
|
|
@ -54,6 +54,20 @@ Capybara::SpecHelper.spec '#within_frame', requires: [:frames] do
|
||||||
end
|
end
|
||||||
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
|
it "should find multiple nested frames" do
|
||||||
@session.within_frame 'parentFrame' do
|
@session.within_frame 'parentFrame' do
|
||||||
@session.within_frame 'childFrame' do
|
@session.within_frame 'childFrame' do
|
||||||
|
|
Loading…
Add table
Reference in a new issue