Create Script In AutoIt To Upload File

Before creating in addition to running file upload script In AutoIT, You must hold out aware close what Is AutoIT in addition to how to Install It. I convey already described close AutoIT In THIS POST in addition to how to download in addition to Install It In THIS POST. Now allow us acquire how to practise script In AutoIT to upload file using selenium webdriver.

In this section, We volition acquire how to practise in addition to run AutoIt script stand upwards alone. Next ship service volition depict you lot how to Integrate AutoIT script alongside selenium webdriver.

Identify objects properties of File Upload dialog
First of all you lot take away to Identify objects of file upload dialog. Navigate to THIS PAGE where you lot volition let on file uploading functionality. Click on Browse button. It volition opened upwards file uploading dialog every bit shown In bellow Image.

To Identify objects of dialog, AutoIt has Windows Info tool. You tin dismiss opened upwards It from Start -> All Programs -> AutoIt V3 -> AutoIt Windows Info.


To Identify object properties of Upload dialog, Simply drag in addition to driblet "Finder Tool" from AutoIT v3 windows Info tool to "File name" champaign every bit shown In higher upwards Image. It volition automatically Identify object properties of File Upload dialog in addition to File advert field. Same means you lot tin dismiss Identify properties of whatever object of whatever dialog. We volition usage that object belongings In automobile It script. In this example, Our object properties are every bit bellow.
  • File upload dialog : Title = File Upload, Class = #32770
  • File advert field : Edit1 (Class + Instance combination)
  • Open button : Button1 (Class + Instance combination)
Write AutoIt script to conduct file In dialog
File "Test.txt" (which I wants to upload) Is located at E:\AutoIT location. To write file upload script, you lot take away to use SciTE Script Editor. Open script editor from Start -> All Programs -> AutoIt V3 -> SciTE Script Editor in addition to write bellow given script In to It in addition to relieve It every bit "Script To Upload File.au3". Script explanation Is given alongside each line.

Note : Test.txt file should hold out located at "E:\AutoIT" folder.

; It volition hold back for 8 seconds to appear File Upload dialog. ; Used Title belongings of File upload dialog window.    WinWait("File Upload","",8)  ; Set command focus to File advert Input box of File Upload dialog. ; Used Class belongings of File upload dialog window in addition to Class+Instance belongings for File advert Input box.    ControlFocus("[CLASS:#32770]","","Edit1")    Sleep(3000)  ; Set the advert of file In File advert Edit1 field. ; "Test.txt" file Is located In AutoIT folder of eastward drive. So nosotros convey to furnish amount path similar E:\AutoIT\Test.txt.    ControlSetText("[CLASS:#32770]", "", "Edit1", "E:\AutoIT\Test.txt")    Sleep(3000)  ; Click on the Open push of File Upload dialog.    ControlClick("[CLASS:#32770]", "","Button1");

In higher upwards script, We convey used amount 5 dissimilar AutoIT commands. Explanation Is every bit bellow.
  • WinWait : Used to hold back for given fourth dimension to appear targeted dialog window.
  • ControlFocus : Set the focus on targeted dialog window.
  • Sleep : Wait for given time.
  • ControlSetText : Write text In targeted Input text champaign of dialog.
  • ControlClick : Click on targeted push of win. dialog.
Your script volition looks similar bellow In AutoIt editor.



Convert script In executable format
To run this script, We take away to convert It In executable .exe format. It Is real uncomplicated because AutoIT has built In component to convert script In .exe format.

To convert script, 
  • Simply acquire to the folder where "Script To Upload File.au3" file Is stored.
  • Right click on file in addition to conduct Compile Script every bit shown In bellow Image. It volition practise "Script To Upload File.exe" file In same folder.


CLICK HERE to download laid made "Script To Upload File.au3" and "Script To Upload File.exe" files of AutoIt.

Test AutoIt script
Now you lot tin dismiss examine script to verify Is It working fine or not.

To examine script, 
  • File Upload dialog should hold out opened. Go to THIS TEST PAGE In Firefox browser in addition to click on "Browse" push to open File Upload dialog.
  • Double click on "Script To Upload File.exe" file to execute script in addition to detect actions on File Upload dialog. It volition come inward file path In File advert champaign of dialog in addition to hence click on Open push automatically.
If this plant hence your script Is fine. Read adjacent ship service to acquire how to usage "Script To Upload File.exe" file In selenium WebDriver examine to upload file.

More interesting articles here :Generation Enggelmundus Internet Marketing Tool here :Zeageat IM http://www.software-testing-tutorials-automation.com/
Post a Comment (0)
Previous Post Next Post