Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Add support for /se/file extension command #79

Merged
merged 1 commit into from
Jan 15, 2022

Conversation

TilBlechschmidt
Copy link
Owner

@TilBlechschmidt TilBlechschmidt commented Jan 14, 2022

🔧 Changes

When uploading a file with a locally running browser, one passes the path to a file. Since both browser and client run on the same machine, this works as expected. However, in the case of remote browsers, this does not hold true anymore. To work around this issue, the core selenium team introduced a "workaround" in the form of an extension command at /se/file (used to be just /file).

This extension command takes a JSON object that looks like this:

{
  "file": "<base64-zip>"
}

The content string is a base64 encoded zip file containing a single file. At this stage, it is not known what would happen when the archive contains multiple files. Thus WebGrid will throw an error for now as it would result in undefined behaviour.

When received, the remote endpoint dumps the file into a temporary directory on disk and returns the path to it in a JSON response like this:

{
  "value": "/path/to/somewhere/file.txt"
}

Note that the filename and extension are equal to the ones in the archive in all observed cases. Thus it is assumed to be a requirement and if such a file can not be created, it will be considered an error. To make this unlikely, the implementation in this PR dumps each uploaded file in its own unique, temporary directory.

Additionally, it turned out to be important that all responses have the Content-Type header set to application/json. If it is missing, the java selenium client will not interpret the response. However, neither does it print an error. It just sets all fields to null 🤷

@TilBlechschmidt TilBlechschmidt added Type: Enhancement Feature requests and other improvements/ideas Priority: Medium Default priority if nothing else matches Status: On Hold Waiting for external response/feedback to continue down the issue lifecycle Change: Patch Backwards compatible bug fix, documentation change or similar labels Jan 14, 2022
@TilBlechschmidt TilBlechschmidt added this to the Stable release milestone Jan 14, 2022
@TilBlechschmidt TilBlechschmidt merged commit d44cfb8 into main Jan 15, 2022
@TilBlechschmidt TilBlechschmidt deleted the feature/fileUpload branch January 15, 2022 11:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Change: Patch Backwards compatible bug fix, documentation change or similar Priority: Medium Default priority if nothing else matches Status: On Hold Waiting for external response/feedback to continue down the issue lifecycle Type: Enhancement Feature requests and other improvements/ideas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant