Norayr Sargsyan
Norayr Sargsyan

Reputation: 1868

How to upload multiple files with Selenium RemoteWebDriver?

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?

Upvotes: 0

Views: 292

Answers (2)

Wache
Wache

Reputation: 1

I had the exact same problem. The multiple files method worked fine locally but it failed with Selenium Grid.

In my case, the problem was that I concatenated with " \n ", that worked locally but remote didn't.

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

I see that your case is similar because you concatenated with a blank space after "\n ".

You need to add de newline without blank space "\n"

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

Upvotes: 0

Harish Kumar
Harish Kumar

Reputation: 11

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());

Upvotes: 0

Related Questions