Upload multiple files in Selenium webdriver using AutoIT

This is my one of my favorite topic Upload multiple files in Selenium using AutoIT.

Recently in one of my requirement, we had to upload multiple times. We already know how to upload files in AutoIT but it is not recommended to create multiple AutoIT scripts for uploading files.


We can also upload files in Selenium using Sikuli and Robot class as well but AutoIT is the best way to do this.


I did some googling and finally came to know that using Command Line Parameter in AutoIT we can achieve this.

In this post, I am going to share how to parameterize AutoIT script and integrate into Selenium webdriver.

Upload multiple files in Selenium


I have created the video for the same.



Step 1- Edit AutoIT script

ControlFocus(“File Upload”,””,”Edit1″)
ControlSetText(“File Upload”,””,”Edit1″,$CmdLine[1])
ControlClick(“File Upload”,””,”Button1″)


If you focus on line number 2 where I have used $CmdLine[1] this is the way to pass parameter at run time.

In the same way, we can pass multiple arguments in AutoIT.

Example are-

$CmdLine[0] ; Contains the total number of items in the array.
$CmdLine[1] ; The first parameter.
$CmdLine[2] ; The second parameter.
$CmdLine[nth] ; The nth parameter e.g. 10 if the array contains 10 items.


Step 2- Pass parameters from Selenium script at run time.

Runtime.getRuntime().exec(“C:\\path \\filename.exe”+” “+”file which you want to upload.”);


Program to upload multiple files in Selenium Webdriver using AutoIT


You can try this with Authentication as well in which you can pass username and password at run time which will save a lot of time for you.

If you want to explore authentication in Selenium using AutoIT then below post will help you.


How to handle authentication window in Selenium Webdriver using AutoIT.


I tried this multiple times and worked always. You can also try in local machine and let me know if you are still facing some issue.




  1. jayashree
  2. Arun Jadhav