From jdonagher at gmail.com Tue Dec 4 01:35:38 2007 From: jdonagher at gmail.com (John Donagher) Date: Mon, 3 Dec 2007 22:35:38 -0800 Subject: [SafariWatir-general] Watir seems to "fast" for my application In-Reply-To: <11c8704e0711270355v1b4c2ff2gdd41359ad76eeb60@mail.gmail.com> References: <2b75aeb90711261138l2b541a67p7076a3006cdc37ea@mail.gmail.com> <7957272F-58DC-4AB2-8005-909FE5851853@carbonplanet.com> <2b75aeb90711270338q69abd55crd1e1c4e1c692271f@mail.gmail.com> <11c8704e0711270355v1b4c2ff2gdd41359ad76eeb60@mail.gmail.com> Message-ID: On Nov 27, 2007 3:55 AM, Dave Hoover wrote: > On 11/27/07, Pirkka Hartikainen wrote: > > It's funny, somehow I assumed that Watir would wait for the pages to > > load by default. But I guess it's not that simple. > > It does try to wait for pages to load by default, but there are some > insidious timing issues that I haven't been able to solve, mostly due > to the fact that I haven't been able to replicate the issues on my > laptop ... and due to a lack of time to work on the project. > > If anyone is feeling brave, they could have a look at the page_load > method in http://safariwatir.rubyforge.org/svn/trunk/safariwatir/scripter.rb > (bottom of file) and let me know if anything jumps out at them. > I spent a bit of time on this tonight. Thanks for the hint. Background: I have been hitting this problem on my 1.8GHz Macbook, in both Tiger with Safari 2, and now Leopard with Safari 3. It seems that Safari's DOCUMENT.readyState is misleading - it claims 'complete' when it really isn't. That probably sounds naive, but it's about as close as I can get to whatever the real issue is. Changing one sleep() timeout from 0.4 to 1 seems to fix the problem for me, although I think that implies that, with just a higher timeout, the implementation will still break e.g. for people with slower machines (or whatever the contributing factor is) My patch below. Thanks, John --- scripter.rb 2007-08-23 12:15:05.000000000 -0700 +++ /opt/local/lib/ruby/gems/1.8/gems/safariwatir-0.2.5/safariwatir/scripter.rb 2007-12-03 22:04:25.000000000 -0800 @@ -467,7 +466,7 @@ tries = 0 TIMEOUT.times do |tries| if "complete" == eval_js("return DOCUMENT.readyState") && !@document.URL.get.blank? - sleep 0.4 + sleep 1 handle_client_redirect break else