use swtch_to.parent_frame if available
This commit is contained in:
parent
e448e959e5
commit
fab5c095f6
|
@ -126,17 +126,24 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base
|
|||
# @param [Capybara::Node::Base] a_node frame element
|
||||
#
|
||||
def within_frame(frame_handle)
|
||||
@frame_handles[browser.window_handle] ||= []
|
||||
frame_handle = frame_handle.native if frame_handle.is_a?(Capybara::Node::Base)
|
||||
@frame_handles[browser.window_handle] << frame_handle
|
||||
if !browser.switch_to.respond_to?(:parent_frame)
|
||||
# Selenium Webdriver < 2.43 doesnt support moving back to the parent
|
||||
@frame_handles[browser.window_handle] ||= []
|
||||
@frame_handles[browser.window_handle] << frame_handle
|
||||
end
|
||||
a=browser.switch_to.frame(frame_handle)
|
||||
yield
|
||||
ensure
|
||||
# There doesnt appear to be any way in Webdriver to move back to a parent frame
|
||||
# other than going back to the root and then reiterating down
|
||||
@frame_handles[browser.window_handle].pop
|
||||
browser.switch_to.default_content
|
||||
@frame_handles[browser.window_handle].each { |fh| browser.switch_to.frame(fh) }
|
||||
if browser.switch_to.respond_to?(:parent_frame)
|
||||
browser.switch_to.parent_frame
|
||||
else
|
||||
# There doesnt appear to be any way in Selenium Webdriver < 2.43 to move back to a parent frame
|
||||
# other than going back to the root and then reiterating down
|
||||
@frame_handles[browser.window_handle].pop
|
||||
browser.switch_to.default_content
|
||||
@frame_handles[browser.window_handle].each { |fh| browser.switch_to.frame(fh) }
|
||||
end
|
||||
end
|
||||
|
||||
def current_window_handle
|
||||
|
|
Loading…
Reference in New Issue