Just reviewed questions that may already have the answer, but failed to find anything relevant.
So the site I am testing has a file upload dialog. When you click Select File -> Browse, a Windows File Upload dialog appears when you have to type (or choose with mouse clicks) the path to the file. When you are done, you have to click the Open button. So WebDriver doesn't see these Windows File Upload controls, so I am using Sikuli and AutoIt to type a path and click Open. Both tools work, but this part is unstable. You have to care that windows are not minimized, for example. Another challenge is making sure that wrong characters didn't come from clipboard right before you type the text in the path input field.
One more option I considered was to use something like Post request to the server, but I can't emulate it, since the site uses tokens to cipher all the traffic.
So the question: would you recommend any other options/tools except AutoIt and Sikuli to handle this Windows File Upload dialog?
Thanks, Racoon
driver.sendKeys("full file path")
on the<input>
element. Depending on the implementation of the page you may have to cancel the click event on on the<input>
with a script injection to avoid the Windows dialogue.driver.executeScript("document.addEventListener('click',function handler(event){if(event.target.type==='file')event.preventDefault()},true))
in the page to prevent the dialogue, then execute all the clicks just like a real user and finally calldriver.findElement(By.css("input[type=file]")).sendKeys("full file path")
to assign the file.