mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Merge pull request #1110 from twalpole/iframe
Push nil scope when switching windows and frames to fix issue 1103
This commit is contained in:
commit
7d2733d477
3 changed files with 21 additions and 1 deletions
|
@ -263,9 +263,12 @@ module Capybara
|
|||
# @param [String] name name of a frame
|
||||
#
|
||||
def within_frame(frame_handle)
|
||||
scopes.push(nil)
|
||||
driver.within_frame(frame_handle) do
|
||||
yield
|
||||
end
|
||||
ensure
|
||||
scopes.pop
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -276,7 +279,10 @@ module Capybara
|
|||
# @param [String] handle of the window
|
||||
#
|
||||
def within_window(handle, &blk)
|
||||
scopes.push(nil)
|
||||
driver.within_window(handle, &blk)
|
||||
ensure
|
||||
scopes.pop
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -383,7 +389,7 @@ module Capybara
|
|||
end
|
||||
|
||||
def current_scope
|
||||
scopes.last
|
||||
scopes.last || document
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -42,4 +42,11 @@ Capybara::SpecHelper.spec '#within_frame', :requires => [:frames] do
|
|||
end
|
||||
end
|
||||
end
|
||||
it "should reset scope when changing frames" do
|
||||
@session.within(:css, '#divInMainWindow') do
|
||||
@session.within_frame 'parentFrame' do
|
||||
@session.has_selector?(:css, "iframe#childFrame").should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,4 +35,11 @@ Capybara::SpecHelper.spec '#within_window', :requires => [:windows] do
|
|||
end
|
||||
@session.find("//*[@id='divInMainWindow']").text.should eql 'This is the text for divInMainWindow'
|
||||
end
|
||||
it "should reset scope when switching windows" do
|
||||
@session.within(:css, '#divInMainWindow') do
|
||||
@session.within_window("secondPopup") do
|
||||
@session.find("//*[@id='divInPopupTwo']").text.should eql 'This is the text of divInPopupTwo'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue