thoughtbot/capybara-webkit — pull request #313 by seangeo (2012-04-04 03:28:41+00:00)
Title: Add request timeouts

Hi,

We're using long running capybara-webkit workers in StillAlive and have had some problems with the long timeouts in webkit. Our use case requires reasonably short timeouts, not the 5 or 10 minutes that webkit does by default. Initially we added a timeout at the Ruby layer however, when that is triggered it messes up the protocol between capybara and the webkit_server and subsequent operations fail.

What we needed was a timeout that is triggered within the webkit_server and then propagated back to the Ruby layer. This is what we've implemented here using a QTimer that is bound to a request cycle on the Webkit browser, so if a request doesn't complete before the timeout expires a failure is sent back to capybara-webkit and a Capybara::TimeoutError is eventually raised in the Ruby layer. The webkit_server protocol remains consistent and the connection to webkit_server can continue to be used.

We've also added GetTimeout and SetTimeout commands to webkit_server so the timeout value can be changed dynamically.

Test cases are included and we've also been testing this under reasonably heavy load using a variety of capybara scenarios.

Cheers,
Sean Geoghegan