diff --git a/lib/capybara/driver/base.rb b/lib/capybara/driver/base.rb index 019e19c5..07b79cd7 100644 --- a/lib/capybara/driver/base.rb +++ b/lib/capybara/driver/base.rb @@ -39,7 +39,7 @@ class Capybara::Driver::Base raise Capybara::NotSupportedByDriverError end - def within_popup(popup_handle) + def within_window(handle) raise Capybara::NotSupportedByDriverError end diff --git a/lib/capybara/driver/selenium_driver.rb b/lib/capybara/driver/selenium_driver.rb index b4effc92..4d22e065 100644 --- a/lib/capybara/driver/selenium_driver.rb +++ b/lib/capybara/driver/selenium_driver.rb @@ -140,8 +140,8 @@ class Capybara::Driver::Selenium < Capybara::Driver::Base browser.switch_to.window old_window end - def within_popup(popup_handle, &blk) - browser.switch_to.window(popup_handle, &blk) + def within_window(handle, &blk) + browser.switch_to.window(handle, &blk) end private diff --git a/lib/capybara/session.rb b/lib/capybara/session.rb index f7f28f77..2bbdd0ad 100644 --- a/lib/capybara/session.rb +++ b/lib/capybara/session.rb @@ -30,7 +30,7 @@ module Capybara :all, :attach_file, :body, :check, :choose, :click_link_or_button, :click_button, :click_link, :current_url, :drag, :evaluate_script, :field_labeled, :fill_in, :find, :find_button, :find_by_id, :find_field, :find_link, :has_content?, :has_css?, :has_no_content?, :has_no_css?, :has_no_xpath?, :has_xpath?, :locate, :save_and_open_page, :select, :source, :uncheck, - :visit, :wait_until, :within, :within_fieldset, :within_table, :within_frame, :within_popup, :has_link?, :has_no_link?, :has_button?, + :visit, :wait_until, :within, :within_fieldset, :within_table, :within_frame, :within_window, :has_link?, :has_no_link?, :has_button?, :has_no_button?, :has_field?, :has_no_field?, :has_checked_field?, :has_unchecked_field?, :has_no_table?, :has_table?, :unselect, :has_select?, :has_no_select?, :current_path, :scope_to, :click ] @@ -203,13 +203,13 @@ module Capybara ## # - # Execute the given block within the given popup given the id of that popup. Only works on + # Execute the given block within the given window. Only works on # some drivers (e.g. Selenium) # - # @param [String] locator Id of the popup + # @param [String] locator of the window # - def within_popup(popup_handle, &blk) - driver.within_popup(popup_handle, &blk) + def within_window(handle, &blk) + driver.within_window(handle, &blk) end ## diff --git a/lib/capybara/spec/driver.rb b/lib/capybara/spec/driver.rb index f9661d98..77b45582 100644 --- a/lib/capybara/spec/driver.rb +++ b/lib/capybara/spec/driver.rb @@ -154,40 +154,40 @@ shared_examples_for "driver with frame support" do end end -shared_examples_for "driver with popup support" do - describe '#within_popup' do +shared_examples_for "driver with support for switching windows" do + describe '#within_window' do before(:each) do @driver.visit('/within_popups') end after(:each) do - @driver.within_popup("firstPopup") do + @driver.within_window("firstPopup") do @driver.evaluate_script('window.close()') end - @driver.within_popup("secondPopup") do + @driver.within_window("secondPopup") do @driver.evaluate_script('window.close()') end end it "should find the div in firstPopup" do - @driver.within_popup("firstPopup") do + @driver.within_window("firstPopup") do @driver.find("//*[@id='divInPopupOne']")[0].text.should eql 'This is the text of divInPopupOne' end end it "should find the div in secondPopup" do - @driver.within_popup("secondPopup") do + @driver.within_window("secondPopup") do @driver.find("//*[@id='divInPopupTwo']")[0].text.should eql 'This is the text of divInPopupTwo' end end it "should find the divs in both popups" do - @driver.within_popup("secondPopup") do + @driver.within_window("secondPopup") do @driver.find("//*[@id='divInPopupTwo']")[0].text.should eql 'This is the text of divInPopupTwo' end - @driver.within_popup("firstPopup") do + @driver.within_window("firstPopup") do @driver.find("//*[@id='divInPopupOne']")[0].text.should eql 'This is the text of divInPopupOne' end end it "should find the div in the main window after finding a div in a popup" do - @driver.within_popup("secondPopup") do + @driver.within_window("secondPopup") do @driver.find("//*[@id='divInPopupTwo']")[0].text.should eql 'This is the text of divInPopupTwo' end @driver.find("//*[@id='divInMainWindow']")[0].text.should eql 'This is the text for divInMainWindow'