How to upload the files in Selenium using AutoIt - Blogs

How to upload the files in Selenium using AutoIt

Selenium   WebDriver Test Automation framework allows us to write the automation scripts for web applications and execute them in various browsers.

In some test scenarios, you might need to verify the functionality of uploading the files. The file web element launches the windows file upload dialog to browse and select the files. With the help of selenium WebDriver we can only launch the upload dialog by clicking the file element button, but it can’t interact with upload dialog.

In order to interact with windows dialog we need to use the AutoIt tool. AutoIt is scripting language which is used to automate windows dialogs.

Here are the steps about writing the scripts using AutoIt.

1.       The very first step is download and install the AutoIt tool. To download the AutoIt  use the following  URL

2.        After successful installation of AutoIt  tool, we need to write the AutoIt script for uploading the file. For this, go to directory -> right click -> New -> AutoIt V3 Script



3.       Right click on the new script file and choose Edit Script.



4.       Now the script file will be opened in AutoIt Script editor. Add the file upload script to the editor as shown belowscript


·         WinWaitActive("#32770", "File Upload", 10)

o   This statement will pause the script not to execute the further until 10 seconds to appear the upload dialog

·         Win Flash("File Upload", " " , 4, 500)

o   WinFlash statement is used to flash the window in taskbar about 500 milliseconds

·         ControlSetText("File Upload", " ", "Edit1", "D:\Canarys\images\adi.jpg")

o   ControlSetText command will add the given text into the given control like adding the image path to control Edit1 in this statement

·         ControlClick("File Upload", " ", "Button1")

o   ControlClick command will do the mouse click on Button1

You can notice that in the above statements with first parameter as   #32770 and File Upload, these are the titles or window class names. We can get them by using AutoIt Window Info feature which comes with AutoIt installation as described below:



Drag the finder tool icon on any control you need from upload dialog, AutoIt Window Info tool will give the detailed properties about the control.

5.       Now you need to compile the script. Goto Tools -> Compile as shown below


6.       The script will be compiled and AutoIt will create an executable file which should be used with Selenium WebDriver


7.       Now AutoIt file upload script is ready to use with Selenium WebDriver framework.

Here are the few Selenium WebDriver scripts before you use the AutoIt upload dialog executable.

1.       Launch the browser using WebDriver framework


2.       Access the application, click on login button, fill username and password and click on submit button


3.       Navigate to the menu item or page where file upload control is available on the web page and fill the details. The two important things need to remember here are click on the file upload control and executing the AutoIt file upload script which will interact with the window’s upload dialog.


Hope you learn the usage of AutoIt in Selenium to upload the files. Thank you.


What is Defect? Defect Life Cycle in Software Testing.

Defect is an unexpected behavior of the software application flow against the requirement specificat...

Read More >

What are Frames? How to handle frames in Selenium WebDriver with C#?

IFrame (FullForm: Inline Frame) is an HTML document that is included in another HTML document and is...

Read More >

What is Synchronization? Handling Synchronization in Selenium WebDriver using C#:

Synchronization meaning: when two or more components involved to perform any action, we expect these...

Read More >

Sending Test reports by Email using Office 365, Gmail

Wouldn’t it be great if Test Report are sent automatically across team as soon the Test Execut...

Read More >

Extent Reports in Selenium CSharp (C#)

Reports play a fundamental role when it comes to TESTING. Tester can now  know the real-time r...

Read More >

How to Set Up Selenium WebDriver in Visual Studio Enterprise 2015?

Pre-requisite : Visual Studio Enterprise 2015 application should be installed into the system.Create...

Read More >

Assertions in Coded UI

Let us discuss how to add assertions in coded UI. Assertions are checkpoints/benchmarks to UI c...

Read More >

Analysis of Load Test Results

Analysis of Performance DataAfter you capture and consolidate your results, analyze the captured dat...

Read More >

Parallel Execution using Selenium Webdriver and TestNG

While testing a web application it is very important to test the application on different browsers. ...

Read More >


Try DevOpSmartBoard Ultimate complete Azure DevOps End-to end reporting tool

Sign Up

  • Recent
  • Popular
  • Tag
Monthly Archive

Contact Us
  • *
  • *