Selenium with AutoIT

Selenium with AutoIT

Many a times while we are automating our test process, we come across situations where we have to deal with a non web component of the application. Selenium can only work with a web element, so how do we deal with scenarios which have non web component as well. Especially if the component is window based? One of the solutions is to bypass such test scenarios in automation, and do them manually. But challenge arises when we have quite a few scenarios depended on flows which have both the web and window controls.

Test Scenario
Let us create this test scenario, by using an application called as This web application allows us to upload a png file, and provides us back with a compressed version.

Now as you can see the window which opens in here for uploading the file cannot be handled by Selenium, as the controls on them are Window based. So we will require a tool which allow us to type the file name, and press on the open button to provide the file to the application for uploading.

AutoIT – A tool to automate the Windows
AutoIT, is a very famous open source tool available out there which can recognize window controls. It also has a rich set of commands available to work on the different types of window objects. You can download AutoIT from –

When you download and install AutoIT , you will find a helpful component called as AutoIT window info. This component allows us to recognize the objects of the windows and fetch their properties to be used in automating them. Below screenshot shows the tool in action as it recognizes the property of the open button in the file dialogue window.

AutoIT Script

The AutoIT script which we create for the file upload is as follows –

You are then required to compile and build the script which will convert this .au3 file into an .exe file. This exe file will be called from within the test written using the selenium webdriver commands.

Calling AutoIT from Selenium Script

The following code snippet shows, that we can call the AutoIT exe file where we have written the steps to upload the file. Ensure that you have a file names uploadimage.png available in the desktop. Or pass the file path as argument to the AutoIt exe file.

No comments

Leave a reply

Your email is never published nor shared. Required fields are marked *