code: public void setScriptWait(int scriptTimeout) {
          try {
              driver().manage().timeouts().setScriptTimeout(scriptTimeout, TimeUnit.MILLISECONDS);
          } catch (Exception e) {
              // https://code.google.com/p/selenium/issues/detail?id=6015
              System.err.println("Unable to set script timeout (known issue for Safari): " + e.getMessage());
          }
      }
docs: Sets how long to wait when executing asynchronous script calls.
  @param scriptTimeout time in milliseconds to wait.