How to pass arguments to an AutoIt script from Selenium


I made a Selenium script to download an Excel sheet, open, edit and upload it back. I use AutoIt for the file upload.

I have different files to upload for each run, so I can't hard code the file path, hence I want to pass it (to the AutoIt script) as an argument. The AutoIt script:

ControlFocus("File Upload", "", "Edit1") Sleep(1000) ControlSetText("File Upload", "", "Edit1", "C:\Users\nilasing\Downloads\somefilename") Sleep(1000) ControlClick("File Upload", "", "Button1")

"C:\Users\nilasing\Downloads\somefilename" is the hard coded path.


You can pass in command line parameters to the script, then read them using the $CmdLine array.

ControlFocus("File Upload", "", "Edit1") Sleep(1000) ControlSetText("File Upload", "", "Edit1", $CmdLine[1]) Sleep(1000) ControlClick("File Upload", "" , "Button1")

See <a href="https://www.autoitscript.com/autoit3/docs/intro/running.htm#CommandLine" rel="nofollow">https://www.autoitscript.com/autoit3/docs/intro/running.htm#CommandLine</a> for more information.


I've used the same method: In my AutoIT au3 file -

ControlFocus("File Upload","","Edit1") ControlSetText("File Upload","","Edit1",$CmdLine[1]) ControlClick("File Upload","","Button1")

Then call the AutoIT executable from Selenium WebDriver with -

String fileName = "C:\\Calendar.xls"; // passed as a command line parameter to AutoIT executable below String autoITExecutable = ".\\AutoITFileUploadWithParam.exe " + fileName; ....... try { Runtime.getRuntime().exec(autoITExecutable); Thread.sleep(5000); test.log(LogStatus.INFO, "Ran AutoIT script to upload : " + fileName); } catch (Exception e) { test.log(LogStatus.ERROR, "Failed to run AutoIT script : " + e.getMessage()); } driver.findElement(By.xpath("//div[text()='Send']")).click(); test.log(LogStatus.INFO, "Email sent");

Note the space between the AutoIT executable and the parameter in String autoITExecutable


  • Delete an item in a listbox with a button, in wpf MVVM
  • Tkinter button 'not defined' when ran
  • I can't show LinearLayout at bottom to scroll view
  • Android Custom dialog inflating from layout - alignment issue
  • a concept similar to pointers in as3?
  • LibGdx GLES2.0 cube texel stretching
  • Meteor.. accounts- password— Create account on client without login
  • Iterate through permissions on a file in the windows file system in C#
  • custom string delimiters stringtemplate-4
  • Comparing user's facebook/twitter friends to site's users in Python/Django
  • c# winform DrawToBitmap offscreen
  • Is it safe to drop the -webkit vendor prefix from the css3 border-radius yet?
  • change color of jstree node
  • A class implementing two different IObservables?
  • countdown bar android example
  • Translating C# to PowerShell in InterIMAP
  • import scipy.sparse failed
  • aapt.exe'' finished with non-zero exit value 1
  • How to specify input and output paths from cmd.exe for a PowerShell script?
  • Unexpected token ILLEGAL while running node.js mocha test
  • cygwin cannot exec 'git-add--interactive' permission denied
  • MS Access - How to change the linked table path by amend the table
  • Unable to decode certificate at client new X509Certificate2()
  • Ajax calls do not work in IE unless you fiddle with security settings
  • Alternative to overridePendingTransition() - Android
  • Rails Find when some params will be blank
  • Make VS2015 use angular-cli ng at build time in a .NET project
  • MongoError: Incorrect arguments
  • C++ Partial template specialization - design simplification
  • Using $this when not in object context
  • Jenkins: How To Build multiple projects from a TFS repository?
  • How to make a tree having multiple type of nodes and each node can have multiple child nodes in java
  • How do I fake an specific browser client when using Java's Net library?
  • How reduce the height of an mschart by breaking up the y-axis
  • Cassandra Data Model
  • Perl system calls when running as another user using sudo
  • Apache 2.4 - remove | delete | uninstall
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Codeigniter doesn't let me update entry, because some fields must be unique
  • How to get NHibernate ISession to cache entity not retrieved by primary key