How to Handle Windows Pop-up Using AutoIt and Selenium Automation Testing

Pop-ups are those irritating windows that come up while we work on something important and interrupt our concentration. It is necessary to get rid of them while testing.

In this article, we shall discuss how to handle window pop-ups in automation testing using AutoIt.

This tutorial covers:

But first, let’s understand what is AutoIt, how to install and use it.

What You Will Learn:

What is AutoIt?

AutoIt V3 is a freeware tool which is used for automating anything in Windows environment. AutoIt script is written in a BASIC language. It can simulate any combination of keystrokes, mouse movement and window/control manipulation.

Through AutoIt, we can prepare scripts for our routine actions like file input/output operations, application handling, resources monitoring, and administrative tasks and so on. However, in this article, we shall limit our discussion to handling window pop-ups in Selenium WebDriver.

While doing automation through Selenium or through any other tool for that matter, we all encounter a common problem, windows pop-ups. As Selenium is confined to automating browsers, desktop window is out of scope. Web applications sometimes need to interact with the desktops to perform things like file downloads and uploads. There are tools available for automating these sorts of workflow such as AutoIt, Robot Framework, Silk Test etc.

We can upload or download the files or images by transferring our control from Selenium WebDriver to AutoIt. We need to explicitly call the AutoIt script from our program.

Also, read => How to Handle Alerts/Popups in Selenium WebDriver

AutoIt Download and Installation – Step by step Guide

AutoIt Download: Click here to download AutoItV3 current version and AutoIt Script Editor.

Once downloaded, install the AutoItV3 setup on your system. Follow below steps to install AutoIt.

Step #1 Click on the setup file

Step #2 – Accept the license agreement

Step #3 – Choose 64 bit or 32-bit options based on your operating system: I choose 64 bit

Step #4 – Click on next and select what operation you want to perform by double-clicking: I choose run the script

Step #5 – Choose all the components that are required and click next. You can also choose default where all are checked

Step #6 – Choose file installation location and click on Install. It will take a few seconds to install. Once done, install the script editor

AutoIt Script Editor – Installation

Download the SciTE.exe and install; it is an editor which helps in finding the commands.

How to write AutoIt script:

AutoIt V3 Window Info – finder tool

AutoIt Script to Exe converter:

Download pop-up example:

How to download the file?

You can use the below AutoIt script to handle the download popups:

We have already captured the file download popup properties like Tile, Class, Position, and Size and so on in our previous steps. Now build an AutoIt script using identified windows control:

WinWait("[TITLE:Opening ; CLASS:MozillaDialogClass]","", 10)  //Explanation – “It will wait for the title – opening , type- mozilladialogclass, for 10 secs
If WinExists("[TITLE:Opening ; CLASS:MozillaDialogClass]") Then  // if condition
WinActivate("[TITLE:Opening ; CLASS:MozillaDialogClass]")  // if that title is found it will activate and perform below actions
Send("{DOWN}")  // perform down arrow operation
Sleep(10)   // wait for 10 secs
Send("{TAB}")  // perform tab operation
Sleep(10) // wait for 10 secs
Send("{TAB}") // perform tab operation
Sleep(10)  // wait for 10 secs
Send("{ENTER}")  // press enter button
EndIf  // end of if condition

Upload pop up example:

How to upload the file?

You can use the below AutoIt script to handle the Upload window popup:

Build an AutoIt script using identified windows control:

WinWaitActive("File Upload") // enter the title of the pop up
Send("Path of the file to enter")   // enter the path of the file to upload
Send("{ENTER}") / press enter

Save and compile this script and execute that .exe file in your selenium script where we need to upload the file.

Login Pop-Up Window Example

How to enter username and password to the above login pop-up alert window?

You can use the below AutoIt script to handle the login popup:

WinWaitActive("Authentication Required","","10")
If WinExists("Authentication Required") Then

How to test if your AutoIt script is showing expected results or not without integrating it in your selenium script?

Follow below steps:

Disadvantages of AutoIT:

What else can we use AutoIt for?

Apart from handing windows pop-ups, we can use AutoIt to automate your each and every windows operation like file search, copy file from one location to other, installation of software and so on: Refer below examples –

The script for file search in your computer:

$search = FileFindFirstFile("*How*") // enter the search string
If $search = -1 Then // condition not satisfied show error message
MsgBox(1, "Error", "No files/directories matched the search pattern")
While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
MsgBox(4096, "File:", $file)

Save and compile this script and execute that .exe file in your current working directory. It will search all the files which start with “How” and display a message box.

Further resources: Learning to Script with AutoItV3 here and here – basic getting started guides to start using AutoIt scripting.

Important aspects you should keep in mind while working with AutoIt:


We can use AutoIt to automate anything in a Windows Operating System environment. It is a script that is written in a BASIC language and can handle any type of window pop-ups which we encounter while doing automation testing. It can kindle various things such as combinations of keystrokes, mouse movement and window/control manipulation.

Using AutoIt, we can also handle any interaction issues between Selenium WebDriver and Windows.

Here, we learned how to upload/download file pop-up, but there are also other issues such as browser authentication popup, file search in a particular directory, etc. We can handle all these issues by using AutoIt tool.

You can also write scripts through AutoIt to start a task at a particular time, to schedule a task, to copy a file from one server to another and so on.

Do you have any tips/experience/questions to share on AutoIt tool? Let us know in comments below.