Integrating AutoIT Tool with Selenium WebDriver – Upload an Image Scenario

September 25, 2016

In this tutorial, we will learn Integration of AutoIT tool with Selenium WebDriver. While testing any web application, many a time we come across a situation where we have to interact with “Windows-based UI” elements. One of the most common scenarios is while uploading or downloading an image file.

Selenium WebDriver does not provide any inbuilt functionality to interact with Windows-based UI elements. In this situation, we have to take help of some third party tool. There are hundred’s of third party tools which are available in the market. AutoIT is one of the best open-source, easy to use tool available in the market.

Let us learn integration of AutoIT tool with a practical scenario.

Practical Scenario: Uploading an image on google:

Scenario:

  1. Open a browser of your choice (say Google Chrome)
  2. Navigate to “https://images.google.com/”
  3. Click camera icon –> Upload an Image –> Browse
  4. Window based UI opens up. Refer below images for same.

Upload an Image

Uplad an Image

windows based popup

Now, to interact with this windows-based UI. We will use AutoIT tool.

Environment Setup for AutoIT:

Steps to follow:

  1. Download and install AutoIT tool and its editor.

Refer the screenshot below:

autoit download

After installing AutoIT tool, open the editor and write the script. Now here, the script will be first, wait for the upload window to get active and  then pass the absolute path of the image and  then press enter.

Title of the window:

For Mozilla Firefox: Upload File

For Chrome: Open

See the below screenshot for the reference.

autoitscript

After completing the script, to execute it first compile the code. After compiling the code an exe file will be generated.

Call this exe in your selenium code by below command:

Refer below code for complete scenario:

This is how AutoIT tool can be integrated with Selenium.

For any questions, queries or comments feel free to write us at support@qatechhub.com or saurabh@qatechub.com. Happy Learning 🙂

Saurabh

About the Author

Saurabh

Follow Saurabh:

Leave a Comment: