Q:

How can I use Autoit to close all javascript alerts and confirmations that may appear?

I am testing in selenium and I have a bunch of stuff that happens on page load. I found out about autoit, and I was thinking that it could handle all javascript dialog issues. I was searching around the web for some autoit script that could handle this... 
Other options would be helpful as well!
I don't necessarily need all the code, but some point in the right direction would be helpful.

A:

Alright so this solution works for me... I was able to close 2 windows here. Also I will be able to handle popups based on their name which is cool. It always runs in the background after I have lauched the script. When I want it to end I simply close autoit from task manager or from the task bar area on the right. 
While True
If WinWait('Name of your Popup', '', 1) == 1 Then
    ;Wait for page to load if found
    Sleep(10000)
    ;Close Page
    Send('!{F4}') 
    Sleep(5000)
    ;Confirm Dialog
    Send('{ENTER}') 
    Sleep(1000)
    ;Close Lanucher Page
    Send('!{F4}') 
    Sleep(5000)
    ;Confirm Dialog
    Send('{ENTER}') 
EndIf
;Let another thread have a turn
sleep(3)
WEnd

Also this is possible from directly within python, details: http://www.parrisstudios.com/?p=308, but you still need autoit3.

