Browse files

retry a command up to 3 times after a WebkitInvalidResponseError

  • Loading branch information...
1 parent 8d2251d commit 0e303fdf123498bdbd7242735443c5634d0b9d9d @ngauthier committed Oct 31, 2011
Showing with 18 additions and 8 deletions.
  1. +18 −8 lib/capybara/driver/webkit/browser.rb
View
26 lib/capybara/driver/webkit/browser.rb
@@ -64,14 +64,7 @@ def frame_focus(frame_id_or_index=nil)
end
def command(name, *args)
- @socket.puts name
- @socket.puts args.size
- args.each do |arg|
- @socket.puts arg.to_s.bytesize
- @socket.print arg.to_s
- end
- check
- read_response
+ retry_command(0, name, *args)
end
def evaluate_script(script)
@@ -212,5 +205,22 @@ def default_proxy_options
:pass => ""
}
end
+
+ def retry_command(count, name, *args)
+ @socket.puts name
+ @socket.puts args.size
+ args.each do |arg|
+ @socket.puts arg.to_s.bytesize
+ @socket.print arg.to_s
+ end
+ check
+ read_response
+ rescue Capybara::Driver::Webkit::WebkitInvalidResponseError => ex
+ if count > 2
+ raise ex
+ else
+ retry_command(count+1, name, *args)
+ end
+ end
end
end

0 comments on commit 0e303fd

Please sign in to comment.