Если придерживаться подхода робота не важно, я бы посоветовал вам обработать загрузку файла следующим образом:
// Find file input element
WebElement input = driver.findElement(By.cssSelector("input[type='file']"));
// Make sure element is visible
((JavascriptExecutor) driver).executeScript("arguments[0].style.display = 'block';", input);
// Specify you local file path here
input.sendKeys("/path/to/file/on/machine/which/runs/tests");
В случае RemoteDriver не забудьте добавить это:
// Configure your client to upload local files to remote Selenium instance
driver.setFileDetector(new LocalFileDetector());
ПРИМЕЧАНИЕ: путь к файлу должен быть абсолютным.Вы можете сделать это следующим образом:
String getFilePath(String filePath) {
new File(filePath).absolutePath
}