title: Upload files to site automatically without browser focus
body: <p>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 <code>Selenium WebDriver</code>. I use <code>AutoIT</code> script to handle dialog window, file chooser window. Parameter <code>$CmdLine[1]</code> contains the path of actual file.</p>
  
  <pre><code>ControlFocus("Open a file","","Edit1")
  ControlSetText("Open a file","","Edit1", $CmdLine[1])
  ControlClick("Open a file","","Button1")
  </code></pre>
  
  <p>It is executed with this code:</p>
  
  <pre><code>Runtime.getRuntime().exec(autoITExecutable);
  </code></pre>
  
  <p>It opens dialog window, so it can't work without focus on browser window. <code>java.awt.Robot</code> class works similar, it needs focus on browser window.</p>
  
  <p>I tried to use <code>sendKeys()</code> method too, but input field is unable to handle file in this way. <code>Katalon Studio</code> is also unable to handle this field.</p>
  
  <p>Example sites with similar forms:</p>
  
  <p><a href="http://ajaxuploader.com/demo/simple-upload.aspx" rel="noreferrer">http://ajaxuploader.com/demo/simple-upload.aspx</a></p>
  
  <p><a href="https://ec.europa.eu/cefdigital/DSS/webapp-demo/validation" rel="noreferrer">https://ec.europa.eu/cefdigital/DSS/webapp-demo/validation</a></p>
  
  <p><a href="https://tus.io/demo.html" rel="noreferrer">https://tus.io/demo.html</a></p>