selenium: [πŸ› Bug]: Unable to upload file to a Mac Safari node when using selenium Grid.

What happened?

Selenium version : 4.24.0 Java : 11 Platform : MAC Sonoma 14.0 Browser : Safari v 17

I have setup a Selenium Grid with a MAC hub and multiple mac nodes. When i am trying to perform a file upload operation through grid it’s failing and throwing following exception. org.openqa.selenium.InvalidArgumentException: An invalid command argument was specified: One or more files could not be selected.

Please note that on running the test without grid this seems to be working fine. I have tried changing the path with β€œ/” and β€œ\” but nothing seems to be working.

How can we reproduce the issue?

String hub = "http://*.*.*.*:4444/wd/hub";
            SafariOptions options = new SafariOptions();
            options.setCapability("browserName", "safari");
            options.setCapability("platformName", "mac");
            WebDriver driver = null;
            //driver = new RemoteWebDriver(new URL(hub), options);
            RemoteWebDriver driver = new RemoteWebDriver(new URL(hub), options);
            driver.setFileDetector(new LocalFileDetector());
        String filePath = "C:/sample.txt";
        driver.get("https://the-internet.herokuapp.com/upload");
        WebElement element = driver1.findElement(By.id("file-upload"));
        element.sendKeys(filePath);


### Relevant log output

```shell
org.openqa.selenium.InvalidArgumentException: An invalid command argument was specified: One or more files could not be selected.
Build info: version: '4.24.0', revision: '748ffc9bc3'
System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.23'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [BB0D158E-6371-4143-A373-9A3E5296337F, sendKeysToElement {value=[Ljava.lang.CharSequence;@2bd08376, id=node-D15E858C-69C7-4467-8D03-373A0981CD24}]
Capabilities {acceptInsecureCerts: false, browserName: Safari, browserVersion: 17.0, platformName: mac, safari:automaticInspection: false, safari:automaticProfiling: false, safari:diagnose: false, safari:platformBuildVersion: 23A344, safari:platformVersion: 14.0, safari:useSimulator: false, se:bidiEnabled: false, se:cdpEnabled: false, setWindowRect: true, strictFileInteractability: false, webkit:WebRTC: {DisableICECandidateFiltering: false, DisableInsecureMediaCapture: false}}
Element: [[RemoteWebDriver: Safari on mac (BB0D158E-6371-4143-A373-9A3E5296337F)] -> id: file-upload]
Session ID: BB0D158E-6371-4143-A373-9A3E5296337F
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at org.openqa.selenium.remote.ErrorCodec.decode(ErrorCodec.java:167)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:138)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:50)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:190)
	at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:53)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
	at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:223)
	at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:110)

Operating System

macOS

Selenium version

4.24.0

What are the browser(s) and version(s) where you see this issue?

Safari

What are the browser driver(s) and version(s) where you see this issue?

Safari 17

Are you using Selenium Grid?

4.24.0

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 21 (10 by maintainers)

Most upvoted comments

One thing you can do is compare what is being sent when running on Mac and when running on Windows Mac flow. Debugging or stepping through (https://github.com/SeleniumHQ/selenium/blob/trunk/java/src/org/openqa/selenium/remote/RemoteWebElement.java#L90) to compare might help. Just a suggestion that popped into my head. Good luck!

Thank you for verifying it works on Mac. RemoteWebDriver is browser-agnostic. Since it works for Chrome/Firefox, that proves that it is doing the right thing and it is not a Selenium bug. It fails at the point where the command goes to SafariDriver and it does not support it. It could be a case of Windows Mac flow and something in SafariDriver that does not work in that case. I would suggest asking in the SafariDriver forums.