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

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 raise Capybara::NotSupportedByDriverError
end end
def within_popup(popup_handle) def within_window(handle)
raise Capybara::NotSupportedByDriverError raise Capybara::NotSupportedByDriverError
end end

View file

@ -140,8 +140,8 @@ class Capybara::Driver::Selenium < Capybara::Driver::Base
browser.switch_to.window old_window browser.switch_to.window old_window
end end
def within_popup(popup_handle, &blk) def within_window(handle, &blk)
browser.switch_to.window(popup_handle, &blk) browser.switch_to.window(handle, &blk)
end end
private 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, :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?, :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, :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?, :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 :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) # some drivers (e.g. Selenium)
# #
# @param [String] locator Id of the popup # @param [String] locator of the window
# #
def within_popup(popup_handle, &blk) def within_window(handle, &blk)
driver.within_popup(popup_handle, &blk) driver.within_window(handle, &blk)
end end
## ##

View file

@ -154,40 +154,40 @@ shared_examples_for "driver with frame support" do
end end
end end
shared_examples_for "driver with popup support" do shared_examples_for "driver with support for switching windows" do
describe '#within_popup' do describe '#within_window' do
before(:each) do before(:each) do
@driver.visit('/within_popups') @driver.visit('/within_popups')
end end
after(:each) do after(:each) do
@driver.within_popup("firstPopup") do @driver.within_window("firstPopup") do
@driver.evaluate_script('window.close()') @driver.evaluate_script('window.close()')
end end
@driver.within_popup("secondPopup") do @driver.within_window("secondPopup") do
@driver.evaluate_script('window.close()') @driver.evaluate_script('window.close()')
end end
end end
it "should find the div in firstPopup" do 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' @driver.find("//*[@id='divInPopupOne']")[0].text.should eql 'This is the text of divInPopupOne'
end end
end end
it "should find the div in secondPopup" do 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' @driver.find("//*[@id='divInPopupTwo']")[0].text.should eql 'This is the text of divInPopupTwo'
end end
end end
it "should find the divs in both popups" do 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' @driver.find("//*[@id='divInPopupTwo']")[0].text.should eql 'This is the text of divInPopupTwo'
end 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' @driver.find("//*[@id='divInPopupOne']")[0].text.should eql 'This is the text of divInPopupOne'
end end
end end
it "should find the div in the main window after finding a div in a popup" do 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' @driver.find("//*[@id='divInPopupTwo']")[0].text.should eql 'This is the text of divInPopupTwo'
end end
@driver.find("//*[@id='divInMainWindow']")[0].text.should eql 'This is the text for divInMainWindow' @driver.find("//*[@id='divInMainWindow']")[0].text.should eql 'This is the text for divInMainWindow'