1
0
Fork 0
mirror of https://github.com/thoughtbot/capybara-webkit synced 2023-03-27 23:22:28 -04:00

Make sure to wait for the desired window to load, not just any window

This commit is contained in:
Matthew Horan 2012-04-04 11:54:09 -04:00
parent 82f84fbde1
commit baf21c99ef

View file

@ -1584,7 +1584,15 @@ describe Capybara::Driver::Webkit do
it "waits for the new window to load" do
subject.visit("/new_window?sleep=1")
subject.within_window(subject.window_handles.last) do
lambda { Timeout::timeout(1) { subject.find("//p") } }.should_not raise_error(Timeout::Error)
subject.find("//p").first.text.should == "finished"
end
end
it "waits for the new window to load when the window location has changed" do
subject.visit("/new_window?sleep=2")
subject.execute_script("setTimeout(function() { window.location = 'about:blank' }, 1000)")
subject.within_window(subject.window_handles.last) do
subject.find("//p").first.text.should == "finished"
end
end