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
Sorry about that! I added this solution to the wiki. It would be nice
to know if it works well for others. I couldn't seem to get any of the
other suggestions to work for me.
-George
On Mar 4, 1:14 am, Željko Filipin <zeljko.fili...@wa-research.ch>
wrote:
at_exit is not killing them, and if I do only: Process.kill(9,@pid),
then the popup is not closing, maybe because the process is being
killed before the click.
Any idea?
On Mar 5, 2:20 am, Željko Filipin <zeljko.fili...@wa-research.ch>
wrote:
-George
On Mar 16, 5:27 pm, Shlomit Gazit <shlomitpatr...@gmail.com> wrote:
> George,
> Your solution is the only one that is working for me for handling
> popups. Thank you!
> Minor thing I couldnt figure out:
> Each time that there is a popup, ruby.exe process is being created. At
> the end of the test, I have lots of ruby.exe processes running, and if
> I have multiple testes running one after another, I have even more
> ruby.exe processes alive.
>
> at_exit is not killing them, and if I do only: Process.kill(9,@pid),
> then the popup is not closing, maybe because the process is being
> killed before the click.
>
> Any idea?
>
> On Mar 5, 2:20 am, Željko Filipin <zeljko.fili...@wa-research.ch>
> wrote:
>
>
>
> > On Thu, Mar 4, 2010 at 6:04 PM, George <george.sand...@gmail.com> wrote:
> > > I added this solution to the wiki.
>
> > Thanks!
>
> > > It would be nice
> > > to know if it works well for others. I couldn't seem to get any of the
> > > other suggestions to work for me.
>
> > If it works for you, it could help somebody else. Personally, I always
> > insist that the application does not havepop-ups. I just refuse to automate