---Advertisement---

AutoIT in Selenium WebDriver: Complete Tutorial for Handling File Uploads Best 2025

By Manisha

Updated On:

---Advertisement---
AutoIT in Selenium WebDriver

👉AutoIT in Selenium WebDriver

AutoIT in Selenium WebDriver : AutoIT is a free scripting language used to automate Windows GUI operations. When working with Selenium WebDriver, it’s often necessary to handle system-level pop-ups like file upload windows, which Selenium alone cannot control. This is where AutoIT becomes incredibly useful. It simulates keyboard actions, mouse clicks, and window controls to handle these native OS elements.


👉Table of Contents:

  1. Why Use AutoIT with Selenium?
  2. How to Download and Install AutoIT
  3. Using AutoIT for File Uploads
  4. Integrating AutoIT with Selenium WebDriver
  5. Conclusion

👉Why Use AutoIT with Selenium?

AutoIT in Selenium WebDriver : Selenium WebDriver cannot interact with Windows-based pop-ups such as file upload dialogs, print pop-ups, or native apps like Notepad and Calculator. AutoIT overcomes this limitation by allowing automation of Windows GUI elements that Selenium cannot handle.


👉 How to Download and Install AutoIT

  1. Visit the
  2. Navigate to the Downloads section and download both:
    • AutoIT (the main scripting tool)
    • AutoIT Script Editor (SciTE)
  3. Install both .exe files on your system.
  4. After installation, open the editor from: javaCopyEditC:\Program Files (x86)\AutoIt3\SciTE\SciTE.exe
  5. Also, open AutoIT Element Identifier from: javaCopyEditC:\Program Files (x86)\AutoIt3\Au3Info.exe

🔍 Note: Element Identifier helps in inspecting Windows GUI elements and is similar to the Selenium IDE.


👉 Using AutoIT for File Uploads

AutoIT in Selenium WebDriver : Let’s walk through an example of uploading a file using AutoIT on a web page form.

  • Open Au3Info.exe.
  • Click the “Choose File” button on the form.
  • Drag the Finder Tool to the file name input box.
  • Capture:
    • Title: Open
    • Class: Edit
    • Instance: 1
    • Control ID: Edit1

Go to:

javaC:\Program Files (x86)\AutoIt3\SciTE\SciTE.exe

Start writing your script using the following methods:

autoitControlFocus("Open", "", "Edit1")
ControlSetText("Open", "", "Edit1", "C:\path\to\your\file.doc")
ControlClick("Open", "", "Button1")

✅ ControlFocus – focuses the cursor on the input field
✅ ControlSetText – sets the file path
✅ ControlClick – clicks the “Open” button

  • Save the script as FileUpload.au3
  • Right-click the file → Compile Script (choose 32-bit or 64-bit based on your OS)
  • This generates an .exe file (e.g., FileUpload.exe)

👉 Integrating AutoIT Script with Selenium WebDriver

AutoIT in Selenium WebDriver : Now, use the compiled AutoIT script in your Selenium test case:

javaimport java.io.IOException;

public class FileUpload {
public static void main(String[] args) throws IOException {
// Selenium code to click the 'Choose File' button
// driver.findElement(By.id("uploadButton")).click();

// Call the AutoIT script to handle the file upload
Runtime.getRuntime().exec("E:\\AutoIT\\FileUpload.exe");
}
}
  • After clicking the file upload button in Selenium, control shifts to AutoIT to complete the file upload process.
  • Once done, Selenium resumes and continues the test flow.

👉Conclusion

To handle Windows-based file upload pop-ups in Selenium:

  1. Install AutoIT and its script editor.
  2. Use Element Identifier to inspect GUI elements.
  3. Write and compile your AutoIT script.
  4. Call the .exe script from Selenium.

By using AutoIT with Selenium WebDriver, you can effectively automate actions that are otherwise impossible with Selenium alone — such as interacting with non-HTML elements or native OS pop-ups.

Robot Class in Selenium

Testing Selenium Download

Leave a Comment

Index