Renamed "within_popup" to "within_window"

This commit is contained in:
jarra 2010-08-28 18:50:34 +02:00 committed by Jonas Nicklas
parent 112df90656
commit 2e4bb2e374
4 changed files with 17 additions and 17 deletions

View File

@ -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

View File

@ -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

View File

@ -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
##

View File

@ -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'