Hi,
Whenever there is a modal dialog during a page load, the wait method
will be stuck till someone clicks on the OK or CANCEL to dismiss the
modal dialog.
The code will be stuck in the below while loop the wait method(ie-
class.rb).
begin
while @ie.busy # XXX need to add time out
sleep a_moment
end
ie.add_checker PageCheckers ::HANDLE_MODAL would also not work since
run_error_checks would only work at the end of the wait method.
You would have to make changes to the wait method in C:\ruby\lib\ruby
\gems\1.8\gems\watir-1.6.2\lib\watir\ie-class.rb
Replace the wait method with the below code - will also handle any
security alert, security information, certificate error(ie 6) and
return from the wait method when a popup window is loaded when in the
busy while loop.
http://pastie.org/596458
def wait(no_sleep=false)
@rexmlDomobject = nil
@down_load_time = 0.0
a_moment = 0.2 # seconds
start_load_time = Time.now
outval = ' ' * 30
popwndtitle = ''
#puts "CALLLED WAIT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
begin
while @ie.busy # XXX need to add time out
sleep a_moment
# 1-SECURITY INFORMATION - PAGE CONTAINS BOTH SECURE AND
INSECURE ITEMS YES-6
# 2-Security Alert - Certificate error YES-1
pophwnd = Win32API.new("user32", "GetWindow", 'Li', 'L').Call
(@ie.hwnd.to_i, 6)
# only handle if there is a popup and handle only 2 popups,
if any other popups occur return.
if pophwnd !=0
Win32API.new("user32", "GetWindowText", 'Lpi', 'L').Call
(pophwnd,outval,30)
popwndtitle = outval.rstrip.chomp("\000")
return 0 if !(popwndtitle.include?("Security Alert") ||
popwndtitle.include?("Security Information"))
cntrlhwndYES = Win32API.new("user32", "GetDlgItem", 'Li',
'L').Call(pophwnd, 1)
Win32API.new("user32", "SendMessage",'LLLL','L').Call
(cntrlhwndYES, 0x0006, 1,0)
Win32API.new("user32", "SendMessage",'LLLL','L').Call
(cntrlhwndYES, 0x00F5, 0,0)
cntrlhwndYES = Win32API.new("user32", "GetDlgItem", 'Li',
'L').Call(pophwnd, 6)
Win32API.new("user32", "SendMessage",'LLLL','L').Call
(cntrlhwndYES, 0x0006, 1,0)
Win32API.new("user32", "SendMessage",'LLLL','L').Call
(cntrlhwndYES, 0x00F5, 0,0)
end
end
until @ie.readyState == READYSTATE_COMPLETE do
sleep a_moment
end
sleep a_moment
until @ie.document do
sleep a_moment
end
documents_to_wait_for = [[email protected]]
rescue WIN32OLERuntimeError # IE window must have been closed
@down_load_time = Time.now - start_load_time
sleep @pause_after_wait unless no_sleep
return @down_load_time
end
while doc = documents_to_wait_for.shift
begin
until doc.readyState == "complete" do
sleep a_moment
end
@url_list << doc.location.href unless @url_list.include?
(doc.location.href)
doc.frames.length.times do |n|
begin
documents_to_wait_for << doc.frames[n.to_s].document
rescue WIN32OLERuntimeError, NoMethodError
end
end
rescue WIN32OLERuntimeError
end
end
@down_load_time = Time.now - start_load_time
run_error_checks
sleep @pause_after_wait unless no_sleep
@down_load_time
end
Let me know if you have any issues.
Thanks,
Tony
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Watir General" group.
To post to this group, send email to [email protected]
Before posting, please read the following guidelines:
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---