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

#within_frame method

This commit is contained in:
jgagner 2010-01-12 11:40:10 -08:00
parent 5c20277dfa
commit 8ad161b041
4 changed files with 14 additions and 2 deletions

View file

@ -27,6 +27,10 @@ class Capybara::Driver::Base
raise NotImplementedError raise NotImplementedError
end end
def within_frame frame_id
raise Capybara::NotSupportedByDriverError
end
def source def source
raise NotImplementedError raise NotImplementedError
end end

View file

@ -103,7 +103,12 @@ class Capybara::Driver::Selenium < Capybara::Driver::Base
def browser def browser
self.class.driver self.class.driver
end end
def with_frame(frame_id)
old_window = browser.window_handle
browser.switch_to.frame(frame_id)
yield
browser.switch_to.window old_window
end
private private
def url(path) def url(path)

View file

@ -8,5 +8,5 @@ describe Capybara::Driver::Selenium do
it_should_behave_like "driver" it_should_behave_like "driver"
it_should_behave_like "driver with javascript support" it_should_behave_like "driver with javascript support"
it_should_behave_like "driver without node path support" it_should_behave_like "driver without node path support"
it_should_behave_like "driver with frame support"
end end

View file

@ -1,5 +1,8 @@
require File.expand_path('spec_helper', File.dirname(__FILE__)) require File.expand_path('spec_helper', File.dirname(__FILE__))
shared_examples_for 'driver with frame support' do
it_should_behave_like 'within_frame'
end
shared_examples_for 'driver' do shared_examples_for 'driver' do
describe '#visit' do describe '#visit' do