1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00
teamcapybara--capybara/lib/capybara/spec/session/within_window_spec.rb
2012-07-13 12:59:57 +02:00

40 lines
1.5 KiB
Ruby

shared_examples_for "session with window support" do
describe '#within_window' do
before(:each) do
@session.visit('/within_popups')
end
after(:each) do
@session.within_window("firstPopup") do
@session.evaluate_script('window.close()')
end
@session.within_window("secondPopup") do
@session.evaluate_script('window.close()')
end
end
it "should find the div in firstPopup" do
@session.within_window("firstPopup") do
@session.find("//*[@id='divInPopupOne']").text.should eql 'This is the text of divInPopupOne'
end
end
it "should find the div in secondPopup" do
@session.within_window("secondPopup") do
@session.find("//*[@id='divInPopupTwo']").text.should eql 'This is the text of divInPopupTwo'
end
end
it "should find the divs in both popups" do
@session.within_window("secondPopup") do
@session.find("//*[@id='divInPopupTwo']").text.should eql 'This is the text of divInPopupTwo'
end
@session.within_window("firstPopup") do
@session.find("//*[@id='divInPopupOne']").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
@session.within_window("secondPopup") do
@session.find("//*[@id='divInPopupTwo']").text.should eql 'This is the text of divInPopupTwo'
end
@session.find("//*[@id='divInMainWindow']").text.should eql 'This is the text for divInMainWindow'
end
end
end