From baf21c99ef4fd81ef500b47b37aee79e2a8bc869 Mon Sep 17 00:00:00 2001 From: Matthew Horan Date: Wed, 4 Apr 2012 11:54:09 -0400 Subject: [PATCH] Make sure to wait for the desired window to load, not just any window --- spec/driver_spec.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/spec/driver_spec.rb b/spec/driver_spec.rb index a4569e4..ead44c6 100644 --- a/spec/driver_spec.rb +++ b/spec/driver_spec.rb @@ -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