Hello all,

I was checking out the various solutions presented at
http://wiki.openqa.org/display/WTR/JavaScript+Pop+Ups. I found
another
solution some time ago that isn't listed there. You'll need AutoIt
installed. I'll present it here, and if you think it might help,
please feel free to add it to the list:

First, create a file called 'popup_closer.rb' and add the following
code:

####################################

require 'win32ole'
begin
  autoit = WIN32OLE.new('AutoItX3.Control')
  loop do
   autoit.ControlClick("Windows Internet Explorer",'', 'OK')
   autoit.ControlClick("Security Information",'', '&Yes')
   autoit.ControlClick("Security Alert",'', '&Yes')
   autoit.ControlClick("Security Warning",'', 'Yes')
   autoit.ControlClick("Message from webpage",'', 'OK')
   sleep 3
  end
rescue Exception => e
  puts e
end

####################################

Next, add the following to your working script:

####################################

@pid = Process.create(
    :app_name       => 'ruby popup_closer.rb',
    :creation_flags  => Process::DETACHED_PROCESS
    ).process_id
#~ at_exit{ Process.kill(9,@pid) }

####################################

While the script is running, this will continue to check for any
popups and click OK. You can always change the options to "No",
"Cancel", etc.

If you want to kill the process earlier, remove the last line and
just
type: Process.kill(9,@pid).

HTH,

George

-- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general

Reply via email to