I've been using the development gem 1.5.1.1166 which includes the
re-written wait logic to test a complex SAP web application. The main
content that I am automating is nested 4 frames deep. Up until this
past Friday this version of watir seemed to handle waiting for all of
the inner frames to load properly. Now however this wait logic isn't
always waiting until the pages load completely which causes my scripts
to fail. I don't think there have been any changes in the web app I'm
testing which would cause this. I did happen to install the
important/critical Microsoft security patches for June which could have
effected watir?
http://www.microsoft.com/technet/security/bulletin/ms07-jun.mspx
Has any one else experienced this problem with the new wait logic not
waiting quite long enough when there are many nested frames?
I wish this was a public web-app so I could provide an example w/html to
look at but it's not.
> Gems prior to 1.5.1.1166 would either give me the access denied errors
> as it tried to wait for the inner frames to load - or if those were
> suppressed, I had to put in a manual wait whenever I navigated to a new
> page: "sleep 0.1 until some_element_on_inner_frame.exists?". After
> installing 1166 all of these delay problems were fixed... Until now.
>
> Now that this issue has surfaced I'm forced to put the manual delays in
> again. It is not a big deal to do this, but, it's always cleaner if
> watir handles the delays properly.
In order to help narrow down the issue i've included a test script below which adds some extra logging to the watir wait method, and provides an example of the output I get when running it against my application.
###############TEST SCRIPT ################
require 'watir'
module Watir
class IE
# Block execution until the page has loaded.
# =nodoc
# Note: This code needs to be prepared for the ie object to be closed at
# any moment!
def wait(no_sleep=false)
@rexmlDomobject = nil
@down_load_time = 0.0
a_moment = 0.2 # seconds
start_load_time = Time.now
begin
while @ie.busy # XXX need to add time out
sleep a_moment
end
until @ie.readyState == READYSTATE_COMPLETE do
sleep a_moment
end
sleep a_moment
until @ie.document do
sleep a_moment
end
docNum = 0
documents_to_wait_for = [@ie.document]
rescue WIN32OLERuntimeError # IE window must have been closed
@down_load_time = Time.now - start_load_time
sleep @defaultSleepTime unless no_sleep
return @down_load_time
end
while doc = documents_to_wait_for.shift
docNum +=1
begin
tsleep = Time.now
until doc.readyState == "complete" do
sleep a_moment
end
tsleep = Time.now - tsleep
puts "** waited #{tsleep} seconds for doc['#{docNum}'].readyState == 'complete'"
numFrames = doc.frames.length
@url_list << doc.url unless @url_list.include?(doc.url)
doc.frames.length.times do |n|
begin
documents_to_wait_for << doc.frames[n.to_s].document
puts "\t ** Adding Frame #{n+1} of #{numFrames} of document:'#{docNum}' as doc['#{docNum + n+1}']"
rescue WIN32OLERuntimeError
puts "\t ** WIN32OLERuntimeError Raised and Handled when Adding Frame #{n+1} of #{numFrames} of document:'#{docNum}' as doc['#{docNum + n+1}'] \n #{$!} \n\n"
end
end
rescue WIN32OLERuntimeError
puts "WIN32OLERuntimeError Raised and Handled when processing frames for doc['#{docNum}'] \n#{$!} \n #{$@.join("\n")} \n\n"
end
end
@down_load_time = Time.now - start_load_time
run_error_checks
sleep @defaultSleepTime unless no_sleep
@down_load_time
end
end
end
ie = Watir::IE.attach(:title,/SAP Netweaver/i)
puts "\n\n\n ****** Going to Accounts Screen Now ********"
ie.link(:text,'Accounts').click
dtime = ie.down_load_time
t = Time.now
#wait until the content of the innner frame is realy done loading.
sleep 0.1 until ie.frame(:name,/Desktop/).frame(:id,'isolatedWorkArea').frame(:name, 'crmA').frame(:name,/_B/).cell(:text,'Accounts').exists?
t = Time.now - t
puts "Navigated to Accounts: Watir waited:#{dtime} seconds - Inner Frame content wasn't available for another #{t} seconds"
########SCRIPT OUTPUT###############
****** Going to Accounts Screen Now ********
** waited 0.0 seconds for doc['1'].readyState == 'complete'
** Adding Frame 1 of 3 of document:'1' as doc['2']
** Adding Frame 2 of 3 of document:'1' as doc['3']
** Adding Frame 3 of 3 of document:'1' as doc['4']
** waited 0.0 seconds for doc['2'].readyState == 'complete'
** waited 0.0 seconds for doc['3'].readyState == 'complete'
** waited 0.656 seconds for doc['4'].readyState == 'complete'
** Adding Frame 1 of 2 of document:'4' as doc['5']
** Adding Frame 2 of 2 of document:'4' as doc['6']
** waited 0.0 seconds for doc['5'].readyState == 'complete'
** waited 0.625 seconds for doc['6'].readyState == 'complete'
** Adding Frame 1 of 1 of document:'6' as doc['7']
** waited 0.0 seconds for doc['7'].readyState == 'complete'
** WIN32OLERuntimeError Raised and Handled when Adding Frame 1 of 2 of document:'7' as doc['8']
document
OLE error code:80070005 in <Unknown>
Access is denied.
HRESULT error code:0x80020009
Exception occurred.
** Adding Frame 2 of 2 of document:'7' as doc['9']
WIN32OLERuntimeError Raised and Handled when processing frames for doc['8']
unknown property or method `readyState'
HRESULT error code:0x80070005
Access is denied.
test_wait.rb:38:in `method_missing'
test_wait.rb:38:in `wait'
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1166/./watir.rb:2574:in `click'
test_wait.rb:69
Navigated to Accounts: Watir waited:6.936 seconds - Inner Frame content wasn't available for another 1.297 seconds
####################Frame info #################
$ie.show_frames
there are 3 frames
frame index: 1 name: sapPopupMainId_X0
frame index: 2 name: obnNavIFrame
frame index: 3 name: Desktop Innerpage
ie.frame(:index,3).show_frames
there are 2 frames
frame index: 1 name: sapPopupMainId_X0
frame index: 2 name: isolatedWorkArea
ie.frame(:index,3).frame(:index,2).show_frames
there are 1 frames
frame index: 1 name: crmA
ie.frame(:index,3).frame(:index,2).frame(:index,1).show_frames
there are 2 frames
frame index: 1 Access Denied, see
http://wiki.openqa.org/display/WTR/FAQ#access-denied
frame index: 2 name: 4678CFD23E1209F4E100000093225E68_B ####### THIS IS THE FRAME THAT HAS THE CONTENT that watir isn't waiting for to load. #######