0 votes
1 view
in DevOps and Agile by (19.8k points)

I am using Selenium WebDriver and Java and I need to automate the file upload feature. I tried a lot, but the moment the Browse button is clicked and a new window opens the script stops executing further and rather getting stuck. I tried in both FireFox and IE driver but to no avail.

I tried also by calling an AutoIt exe file, but as the new window opens on click of Browse button, the particular statement


couldn't be exeuted. Kindly help

1 Answer

0 votes
by (63.4k points)

The following code should work with Firefox, Chrome and IE Web Drivers.

FirefoxDriver driver = new FirefoxDriver();


File file = null;

try {

    file = new File(YourClass.class.getClassLoader().getResource("file.txt").toURI());

} catch (URISyntaxException e) {




WebElement browseButton = driver.findElement(By.id("myfile"));


I hope this helps!
Welcome to Intellipaat Community. Get your technical queries answered by top developers !