Can’t use Class to automate Windows file upload using AutoIt

I am trying to use autoit for Windows file upload. I am clicking a browse button which will open the windows file upload popup. I want autoit to type the location of the file and click open.

I need to use FF, Chrome, and IE for testing. I am able to get this to work if I use the title, but the problem is that each browser has a different title. I would like to use class, as it is #32700 for all browsers. I’ve tried using class instead of the title, but its not working.

When I use title, everything works fine. Below is an example for Firefox. In this script, the file name is entered and open is clicked.


ControlFocus("File Upload","","Edit1")

ControlSetText("File Upload", "", "Edit1", "SomeFile.txt")

ControlClick("File Upload", "","Button1");

When I try to use class, text is not being entered and the open button is not getting clicked. There are no errors in the autoit script editor, so I’m not sure why this isn’t working.


ControlFocus("[CLASS:#32770]","","Edit1")

ControlSetText("[CLASS:#32770]", "", "Edit1", "SomeFile.txt")

ControlClick("[CLASS:#32770]", "","Button1");

I’ve also tried to add all three browser titles to 1 AutoIt script. The below script is working for FireFox and IE, but doesn’t do anything in Chrome.


Local $OrgFile = "SomeFile.csv"

Local $ControlIDText = "Edit1"

Local $ControlIDButton = "Button1"

Local $Title_FF = "File Upload"

Local $Title_Chrome = "Open"

Local $Title_IE = "Choose File to Upload"
;FireFox Import

ControlFocus($Title_FF,"",$ControlIDText)

ControlSetText($Title_FF, "", $ControlIDText, $OrgFile)

ControlClick($Title_FF, "",$ControlIDButton);
;Chrome Import

ControlFocus($Title_Chrome,"",$ControlIDText)

ControlSetText($Title_Chrome, "", $ControlIDText, $OrgFile)

ControlClick($Title_Chrome, "",$ControlIDButton);
;IE Import

ControlFocus($Title_IE,"",$ControlIDText)

ControlSetText($Title_IE, "", $ControlIDText, $OrgFile)

ControlClick($Title_IE, "",$ControlIDButton);

jgubbels Default Asked on June 2, 2015 in Selenium WebDriver.
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.