Okay, so: autoit. Here's some code that I got off another site that
doesn't work to dismiss popups:
require 'watir'
require 'watir/dialog'
def check_for_popups
autoit = WIN32OLE.new('AutoItX3.Control')
#
# Do forever - assumes popups could occur anywhere/anytime in your
application.
loop do
# Look for window with given title. Give up after 1 second.
ret = autoit.WinWait('Windows Internet Explorer', '', 1)
#
# If window found, send appropriate keystroke (e.g. {enter},
{Y}, {N}).
if (ret==1) then autoit.Send('{enter}') end
#
# Take a rest to avoid chewing up cycles and give another
thread a go.
# Then resume the loop.
sleep(3)
end
end
#
# MAIN APPLICATION CODE
# Setup popup handler
$popup = Thread.new { check_for_popups } # start popup handler
at_exit { Thread.kill($popup) } # kill thread on exit of
main application
link = 'http://www.w3schools.com/js/tryit_view.asp?
filename=tryjs_alert'
ie = Watir::IE.start(link)
# ensure popup won't block Watir
ie.button(:value, 'Display alert box').click!
dialog = Watir::Dialog.new
# Need to be able to poll window to exist
sleep 7.0
# Remember that the only button to click is OK!
dialog.button('OK').click
# Wait for dialog to do its stuff
# and wait for IE to return to live
ie.waitForIE
I got the popup-handling code from
http://wiki.openqa.org/display/WTR/JavaScript+Pop+Ups,
and the rest of it is from http://en.wikipedia.org/wiki/Watir#Handling_pop-ups.
Is the above code put together correctly?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---