How to upload multiple files with Selenium RemoteWebDriver?

255 Views Asked by At

The method is worked fine when I run tests locally, but when tests are run with a Selenium grid or Zalenium the multiple upload method not works.

String path = "a.jpg";
String path1 = "b.jpg";
String path2 = "c.jpg";

element.sendKeys(path + "\n " + path1 + "\n " + path2);

Did anyone solve this issue?

1

There are 1 best solutions below

1
On

For handling files in remote driver you need to set FileDetector. Below is the code to set the file Detector.

RemoteWebDriver remoteWebDriver = new RemoteWebDriver(new URL(hubUrl), getDesiredCapabilties(Browser.REMOTE_WEBDRIVER));
remoteWebDriver.setFileDetector(new LocalFileDetector());