When /^I provoke focus issues in another test process for (\d+) seconds$/ do |seconds|
  seconds = seconds.to_i
  focusRandomNode = %[
    (function() {
      function focusRandomNode() {
        var $nodes = $('a, input, select, textarea, button');
        var index = Math.floor($nodes.length * Math.random());
        var node = $nodes.get(index);
        $(node).focus();
      }
      setInterval(focusRandomNode, 5);
    })();
  ].gsub(/\n/, ' ')
  start_time = Time.now
  end_time = start_time + seconds
  while Time.now < end_time # don't sleep for the whole time because you cannot CTRL+C out of sleep
    visit root_path
    page.evaluate_script(focusRandomNode);
    sleep(5);
  end
end
