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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🔧 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:
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:
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 toapplication/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 tonull
🤷