Skip to main content
1 of 2
Muzzamil
  • 211
  • 1
  • 5

It’s easy with sendKeys method to upload multiple file in one go. Just put a new line character “\n ” between your files. See below sample code.

WebElement inputElement = driver.findElement(By.xpath("xpath of input element"));
String uploadFilePath = "C:/myfile.txt";
String uploadFilePath2 = "C:/myfile2.txt";
String uploadFilePath3 = "C:/myfile3.txt";
inputElement.sendKeys(uploadFilePath + "\n " + uploadFilePath2 + "\n " + uploadFilePath3);

Importance note: new line character is placed between your files, if you combine a string ending with a new line character then you will get the file not found error!

Hope it will help you

Muzzamil
  • 211
  • 1
  • 5