March 3, 2014

Uploading a file using AutoIt

As we all know, Selenium will not support window based elements. To upload/download we need to use some third party tools.

Below post explains how to upload a file from local drive using AutoIt.

(This code is to select a file from window after clicking on browse button from web page, After this we have click on upload button from web page)

WinWaitActive("File Upload")

Write this code in Notepad and save the file as “Upload.au3”
Right Clicked on the created file “Upload.au3” and click on Compile Script.
You will get “Upload.exe” file

Call this file in Selenium script or in RFT script as below:

Process proc = Runtime.getRuntime().exec("C:\\Temp\\ Upload.exe");

Sample Selenium Code using AutoIt upload:

public class Upload {
public WebDriver driver;

public void setUp() throws Exception {
driver= new FirefoxDriver();
public void testTestScenario1() throws Exception
Process proc = Runtime.getRuntime().exec("C:\\Temp\\Upload.exe");
driver.findElement(By.xpath("//input[@title='Upload file']")).click();

public void tearDown() throws Exception {


  1. Really help this post.. Thanks Madhu..

    But the above code works only for Firefox browser.. Not able to upload the file in

    chrome and IE browsers.

    How to upload the file in chrome and IE browsers using AutoIt.

  2. Your information about Software is really interesting. Also I want to know the latest new techniques which are implemented in testing. Please update it in your website.
    Selenium training Chennai

  3. This comment has been removed by the author.

  4. Hi Madhu,
    Thanks a lot for posting this code for file attachment.Finally after many attempts my script got executed..Thanks once again !

  5. can we upload file to hp quality centeR?

  6. Great article, thanks for sharing a helpful information.
    Been looking for this functionality.
    Selenium training in Chennai | Best Selenium training institute in Chennai
    Please keep sharing such articles.