Q. How do I add a generic script timeout?

A. Use the Timeout class …
Example watir:

Timeout::timeout(10)do
  begin
      @b.goto(url)
  rescue Timeout::Error
      puts 'Page took longer than 10 seconds to load'
  end
end
Social tagging:

One Response to Q. How do I add a generic script timeout?

  1. Surbhi

    Hi,

    My question is, how do i set a generic timeout at any point of my script. For e.g. any place where teh browser takes more than 30 seconds to respond, the script should abort and it should give some message.
    I am facing such problem that I have given some wait_untill calls to work with ajax calls. Now sometimes it so happens that the browser just goes on and on, due to the web site’s performance. In such a case the script waits too long, and the overall run time for all the scripts increases painfully. Please suggest