Reputation: 104
driver.findElement(By.xpath("")).click();
String path = "C:\\FileUpload.Av3.exe";
driver.findElement(By.xpath (")).click(); - Browse Button in Web application
try {
Runtime.getRuntime().exec(path); - Execute AutoIT .exe file
} catch (IOException e) {
e.printStackTrace();
}
This works fine with AutoIt.
After line 3 the execution will not continue and the controls are not passed back from Firefox to Selenium.
Upvotes: 1
Views: 2028
Reputation: 1540
Selenium WebDriver cannot handle it. Use sendKeys
to insert the local path to the file in the File Input element:
String path = "C:\FileUpload.Av3.exe";
driver.findElement(By.xpath("/path/to/the/file/input/element")).sendKeys(path);
Please see FAQ docs of Selenium WebDriver.
Upvotes: 4
Reputation: 372
I also got the same issue after clicking on "Download Excel" link. To fix this issue, I used JavascriptExecutor
to get execution control back.
js.executeScript("arguments[0].click();", button);
Upvotes: 0
Reputation: 1555
The Click call is a blocking call, which does not return until the page is loaded. Since the click opens a dialog box, the click will not return until the dialog box is closed.
To get around this, call Click in a seperate thread, and then call the AutoIt script. Once the AutoIt script closes the dialog box, the click will return, and the rest of your test can continue.
Upvotes: 0
Reputation: 2337
Remove try-catch block and use only the below code. Let me know if it is working.
driver.findElement(By.xpath("")).click();
driver.findElement(By.xpath (")).click(); - Browse Button in Web application
String path = "C:\\FileUpload.Av3.exe";
Runtime.getRuntime().exec(path); - Execute AutoIT .exe file
Upvotes: 0