This article is an AutoIt Tutorial for Beginners. You can learn how to download, install and write basic AutoIt scripts to handle windows Pop-ups using AutoIt and Selenium.
Pop-ups are those irritating windows that come up while we work on something important and interrupt our concentration. We need to get rid of them while testing.
Today, we shall discuss how to handle window pop-ups in automation testing using AutoIt.
This tutorial covers the following:
- How to handle Windows pop-ups in Selenium WebDriver,
- Upload or download files or images by transferring our control from Selenium WebDriver to AutoIt
- How to call the AutoIt script from our program
But first, let’s find out what AutoIt is and how to install and use it.
Table of Contents:
- AutoIt Tutorial
- What is AutoIt
- AutoIt Download and Installation – Step by step Guide
- AutoIt Script Editor – Installation
- How to write AutoIt script
- Download the pop-up example
- Upload pop up example
- How do I upload the file
- Login Pop-Up Window Example
- How to enter username and password in the above login pop-up alert window
- What else can we use AutoIt for
- Conclusion
AutoIt Tutorial

What is AutoIt
AutoIt V3 is a freeware tool which is used for automating anything in Windows environment. AutoIt script is written in 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, resource monitoring, and administrative tasks and so on. However, in this article, we shall limit our discussion on 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 windows are out of scope. Web applications sometimes need to interact with the desktops to perform things like file downloads and uploads. There are tools available to automate these sorts of workflows such as AutoIt, Robot Framework, Silk Test etc.
You can upload or download files or images by transferring our controls 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 the steps given below 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 the default where all are checked

Step #6 – Choose the 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 and Install SciTE.exe; it is an editor which helps in finding the commands.

How to write AutoIt script
- Identify the Windows control, through the AutoItV3 Windows Info tool for 64 bit or 32 bit depending on your operating system
- Click on Finder Tool and mouse hover over the object for which you want the properties
- It will capture the properties of pop-ups like Title, Class, Position, Size, Style, Handle and so on
AutoIt V3 Window Info – finder tool

- Then with the help of above-captured properties, write a script in SciTE script editor or in notepad and save the script with .au3 extension
- Now compile the .au3 script using AutoIt Script to EXE converter, which converts .au3 file to .exe file
- In that editor provide the source and destination folder location and click on the convert button, it will create a .exe file
AutoIt Script to Exe converter

- Else right click you’re saved .au3 script, it will show compile options. Select compile to 64bit or compile to32 bit option and will create a .exe file in the same folder.
- Wherever you encounter a download/upload pop-up window in your Selenium test case, execute the .exe file
- Syntax to call .exe file in your script is: Runtime.getRuntime().exec(“path of exe file”);
Download the pop-up example

How do I 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 Controls:
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 do I upload the file
You can use the AutoIt script given below to handle the Upload window popup:
Build an AutoIt script using identified Windows Controls:
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.
Recommended reading =>> Handling file upload in Selenium
Login Pop-Up Window Example

How to enter username and password in 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
Send("username{TAB}")
Send("Password{Enter}")
EndIf'
How do you test if your AutoIt script is showing expected results or not without integrating it into your selenium script?
Follow the steps mentioned below:
- Before compiling your script double click .au3 file – it will show the errors in your script
- If no errors are found then convert your script into a .exe file
- Manually generate the file download pop scenario
- The pop-up is now available, click on the .exe file, it should be able to accept the pop-up and download the file
Disadvantages of AutoIT
- It only works with Windows operating system
- Knowledge of fundamental coding principles is a must
- It is a great tool for professionals but may be a bit complicated for beginners
What else can we use AutoIt for
Apart from handling windows pop-ups, we can use AutoIt to automate each and every windows operation like file search, copy the file from one location to another, installation of software and so on: Refer below examples –
The script for file search on 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") Exit EndIf While 1 $file = FileFindNextFile($search) If @error Then ExitLoop MsgBox(4096, "File:", $file) WEnd FileClose($search)
Save and compile this script and execute that.exe file in your current working directory. It will search for all the files which start with “How” and display a message box.
Further resources: Learn 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:
- Don’t forget to save your script with .au3 extension
- Compile your script and create a.exe executable file
- A pop-up or anything that you want to handle should be present beforehand so that the .exe file can work on it
Conclusion
You can use AutoIt to automate anything in a Windows Operating System environment. It is a script that is written in BASIC language and can handle any type of window pop-ups that 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-ups, but there are also other issues such as browser authentication popup, file search in a particular directory, etc. You can handle all these issues by using the 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 the AutoIt tool? Let us know in the comments section below. You can also post your queries, doubts or any other feedback. We would love to hear from you.







I need to click on “Yes” or “No” buttons of pop up coming in internet explorer(Would you like to make Internet Explorer your default browser?) using AutoIT. I don’t want to disable its settings of default browser. Please help if anybody knows how to handle such kind of popups?
does it use vb script as well? which script we should earn to learn autoit?
I need to know the commands to implement AutoIt with protractor. Facing issue with this. Can someone please help here?
Hi I wanna click the element in menubar, how to do it.
For example want to click file edit. Please guide
It looks nice, but the only role of selenium i see here is calling the auto-it script, can it run any output to selenium so that selenium know whether the operation was successful or not.
Or it’s like selenium can just execute it without much validation on the output
Yes selenium will just executed the script validation part you need to cover in your selenium script.Selenium can open any .exe file.
If you are passionate about Software Testing, there is a meetup happening on Continuous Testing by the Philadelphia Software Testing Meetup group tomorrow (Friday, 9th October). Would look forward to seeing you there. Here is the link to RSVP – http://bit.ly/Philadelphia-Software-Testing-Group
It is posible that Autoit Make an action with a program notificacion as trigger ??? For example open the RING aplication with a notification arrives
Hi, I need to click an element in a desktop window but there is no class, class name, id, etc. And I don’t want to use mouse co-ordinates to click that element. Is there any alternative way to click that element ?
It uses BASIC (Beginner’s All-purpose Symbolic Instruction Code) language
I Have a save as dialog, i need to set the save path and select ok. Can you send the scrpit to do this
Hi,
Is Autoit can be use to data upload from csv file to a desktop application. Can i use, Do while loop and run the recorded script until all the data uploaded. Data is in rows.. may be 1000 rows.
Hardeep
yes
Hai i want to upload file in gmail. when i use the following code i am getting error like
Exception in thread “main” java.io.IOException: Cannot run program “C:\Desktop\FileUpload.exe”: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at gmail.Gmail.main(Gmail.java:59)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
… 5 more
can someone please suggest me the solution
in Java use \\ for where you see \ in Windows
“C:\\Desktop\\FileUpload.exe”
this is because in the context of Java and \\ context the first \ means treat the next character literally, so the end result is the single \ you expected
i am getting error—–‘nasm’ is not recognized as an internal or external command,
operable program or batch file.
Hi
This was really helpful..
I am trying to download a file using AUTOIT, using the following code:
WinWait(“[TITLE:Internet Explorer ; CLASS:IEFrame]”,””, 10)
If WinExists(“[TITLE:Internet Explorer ; CLASS:IEFrame]”) Then
WinActivate(“[TITLE:Internet Explorer ; CLASS:IEFrame]”)
Send(“{DOWN}”)
Sleep(10)
Send(“{TAB}”)
Sleep(10)
Send(“{TAB}”)
Sleep(10)
Send(“{ENTER}”)
EndIf
but this is not working. Pls help debug
if you are using tabs, down is not neccesorry.
I am facing issues with using the below code for IE browser on windows 10 OS.
WinWaitActive(“Authentication Required”,””,”10″)
If WinExists(“Authentication Required”) Then
Send(“username{TAB}”)
Send(“Password{Enter}”)
EndIf’
Does anyone know how to resolve this?
You need to post more detail. Try to recreate exactly doing it manually.
Do you have an issue where the Authentication required isn’t in focus, do you need to WinActivate it, or click it with a mouse or something else before sending the {tab}?
Although sending tabs and typing is problematic (better to set form values by name or object id than tab), if you are forced to send password make sure you send raw. If you send by default some characters that might be in a password can trigger AutoIT to interpret them as instructions to hold down shift or do other unexpected thing, send_raw will do as the name suggests
Suppose there is a window popup which accepts username and password, and I use AutoIt to automate it. While the test is running I open note pad parallely at the time of autoit code execution. Will the username and password enter into the window popup or the notepad?
Hi I want to execute below code on remote machine but nothing is happening. I am using Grid+AutoIT set up so I have wriiten piece of code in hub and trying to execute that on node machine remotely. I just reach upto login page but after that no credential is passing by code. I have copied AutoIT .exe script in both machine but no success. but code is running absolutely fine but i am unable to run it on remote machine please help me out.
WinWaitActive(“Authentication Required”,””,”10″)
If WinExists(“Authentication Required”) Then
Send(“username{TAB}”)
Send(“Password{Enter}”)
EndIf’