[Wtr-general] how to tell when IE is *really* done

Danny R. Faught faught at tejasconsulting.com
Tue Nov 28 14:42:15 EST 2006


>From: Bret Pettichord <bret at pettichord.com>
>I this that this patch might fix this problem:
>
>http://jira.openqa.org/browse/WTR-107
>
>I believe that a correct wait procedure needs to check every frame.

Thanks for the pointer. I've upgraded to 1.5.1.1127 to pick up this
change.

It doesn't quite fix the problem, though. The new wait code doesn't
recursively descend into the frames - it only gets the direct children
of the main page. The patch below makes it recursive, and gives me the
correct behavior for my app.

*** watir.rb.bak	Tue Nov 28 13:30:15 2006
--- watir.rb	Tue Nov 28 13:36:37 2006
***************
*** 1676,1681 ****
--- 1676,1700 ----
      #
      include Watir::Utils

+ 		def frame_wait(object, s)
+       if object.document.frames.length > 0
+ 				begin
+ 					0.upto object.document.frames.length-1 do |i|
+ 						until object.document.frames[i.to_s].document.readyState ==
"complete"
+ 							sleep 0.2; s.spin
+ 						end
+ 						url = object.document.frames[i.to_s].document.url
+ 						@url_list << url unless url_list.include?(url)
+ 						frame_wait(object.document.frames[i.to_s], s)
+ 					end
+ 				rescue WIN32OLERuntimeError
+ 				end
+ 			else
+ 				url = @ie.document.url
+ 				@url_list << url unless @url_list.include?(url)
+ 			end
+ 		end
+
      # Block execution until the page has loaded.
      def wait(no_sleep=false)
        @down_load_time = 0.0
***************
*** 1709,1729 ****
          sleep 0.2; s.spin
        end

!       if @ie.document.frames.length > 0
!         begin
!           0.upto @ie.document.frames.length-1 do |i|
!             until @ie.document.frames[i.to_s].document.readyState ==
"complete"
!               sleep 0.2; s.spin
!             end
!             url = @ie.document.frames[i.to_s].document.url
!             @url_list << url unless url_list.include?(url)
!           end
!         rescue WIN32OLERuntimeError
!         end
!       else
!         url = @ie.document.url
!         @url_list << url unless @url_list.include?(url)
!       end
        @down_load_time = Time.now - start_load_time
        run_error_checks
        print "\b" if @enable_spinner
--- 1728,1734 ----
          sleep 0.2; s.spin
        end

! 			frame_wait(ie, s)
        @down_load_time = Time.now - start_load_time
        run_error_checks
        print "\b" if @enable_spinner


More information about the Wtr-general mailing list