Cannot upload files using Selenium with Device Farm

1

I'm trying to sendKeys to a file handler in chrome and am getting:

org.openqa.selenium.UnsupportedCommandException: unknown command: unknown command: session/d9da4fe5dd9a7f504ba9b00cbadb182a/se/file

Based on the response here: https://repost.aws/questions/QUmz8qPXjXSRW_-oQ91h7ESg/selenium-send-keys-not-working-to-input-contains-type-file-with-localfiledetector, Is it correct then that uploading files using Selenium with Device Farm is not supported?

According to this post from the Selenium project they claim to be spec compliant since the spec allows extension commands: https://github.com/SeleniumHQ/selenium/issues/9350#issuecomment-861525547

Other providers such as Saucelabs, Lambdatest, and Browserstack are able to support this capability, but Device Farm does not.

Is there any documentation or information explaining how to upload files with this configuration?

Joe
asked 9 months ago417 views
3 Answers
1

So far our solution has been "Don't use Device Farm"

We wanted to try one workaround but it would have been a decent amount of work without a guarantee that it would even work: Basically we'd upload our test assets somewhere, then have the test machines download them at the beginning of the test (ie: actually making this a part of the test). This works around the issue of transferring the files to the runner, but we decided to stick with our current selenium grid provider instead of pursuing this for now.

Joe
answered 7 months ago
  • Thank you for the information.

    It's really sad that aws team doesn't care such basic and important feature.

0

Hello,

Thank you for reaching out to us.

Kindly allow me to address your query below :

I would like to inform you that the endpoint 'session/<sesssion_id>/se/file' is not a supported Selenium W3C endpoint. Currently, only chromedriver and edgedriver support files uploads, and the endpoint used to upload files is 'session/<sesssion_id>/file'.

In order to use this endpoint please ensure the following:

  1. Selenium is running version 3.14.x or 4.x
  2. Use the “LocalFileDetector” to upload local files.

Here is an example using the “LocalFileDetector”:


LocalFileDetector detector = new LocalFileDetector(); driver.setFileDetector(detector);

File localFile = detector.getLocalFile("<your_filename>"); WebElement uploadElement = driver.findElement(...);

uploadElement.sendKeys(localFile.getAbsolutePath());

Also, Selenium 4.0.0-alpha-1 version and mentioned that in version 4 currently only Selenium ‘4.0.0-alpha-1’ would work to upload the file.


LocalFileDetector detector = new LocalFileDetector(); driver.setFileDetector(detector);

File localFile = detector.getLocalFile("<your_filename>"); WebElement uploadElement = driver.findElement(...);

uploadElement.sendKeys(localFile.getAbsolutePath());


<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>4.0.0-alpha-1</version> </dependency>

Kindly note, the chromedriver and edgedriver implements their own /file endpoint, so the above posted workaround will work for both chrome and edge tests, but not for firefox nor IE.

Thus, as a temporary solution, I would suggest you to switch to Selenium 3.14.x or ‘4.0.0-alpha-1’

Moving ahead, regarding the feature release of the implementation of /se/file with Selenium 4 API to be compliant with Device Farm, I completely understand that the lack of the feature is causing inconvenience however please note since this feature request is with the team, thus it is up to the team as to if/when this potential feature is implemented, and due to the confidentiality of upcoming AWS services and features, we as Support Engineers have limited visibility into the progress of it. Due to this, I'm afraid I won’t be able to provide an ETA regarding its release. You may refer to the What's new with AWS page which will note if such a feature does launch in future [1].

Thank you for your cooperation. We hope this information proves helpful.

Hope you have a great day ahead and Stay Safe!

References

[1] https://aws.amazon.com/new/

AWS
SUPPORT ENGINEER
answered 9 months ago
  • We are currently using Selenium 4.8.3 with the LocalFileDetector.

    Also, Selenium 4.0.0-alpha-1 version and mentioned that in version 4 currently only Selenium ‘4.0.0-alpha-1’ would work to upload the file.

    Are you saying we need to downgrade to 4.0.0-alpha-1?

    Just to understand the issue better, is Device Farm using any intermediate server or are the tests proxied directly to the ChromeDriver?

0

Hi Joe,

Have you find the solution or workaround for this issue: "org.openqa.selenium.UnsupportedCommandException: unknown command: unknown command: session/d9da4fe5dd9a7f504ba9b00cbadb182a/se/file"?

answered 7 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions