I work on test script to automate file uploading to a site and execute script in headless mode. It needs to upload list of files one by one, I develop it based on Selenium WebDriver
. I use AutoIT
script to handle dialog window, file chooser window. Parameter $CmdLine[1]
contains the path of actual file.
ControlFocus("Open a file","","Edit1")
ControlSetText("Open a file","","Edit1", $CmdLine[1])
ControlClick("Open a file","","Button1")
It is executed with this code:
Runtime.getRuntime().exec(autoITExecutable);
It opens dialog window, so it can't work without focus on browser window. java.awt.Robot
class works similar, it needs focus on browser window.
I tried to use sendKeys()
method too, but input field is unable to handle file in this way. Katalon Studio
is also unable to handle this field.
Example sites with similar forms:
http://ajaxuploader.com/demo/simple-upload.aspx