-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Grid] Support auto downloads in Grid #11702
Conversation
f9feab4
to
66bf848
Compare
Codecov ReportPatch and project coverage have no change.
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## trunk #11702 +/- ##
=======================================
Coverage 54.89% 54.89%
=======================================
Files 85 85
Lines 5684 5684
Branches 231 231
=======================================
Hits 3120 3120
Misses 2333 2333
Partials 231 231 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
8264ba5
to
b646a06
Compare
I really think Selenium should manage the directory (in |
@titusfortner - I had to define the ability to specify the home directory because when creating tests, bazel would not allow me to write into the home directory and as such the tests were failing. The only option I had was to alter the The primary intent of allowing a user to specify this flag was to facilitate the tests. This parameter is not a must. If its not specified it defaults to the current user's home directory ( Here's the slack message link which has more details https://seleniumhq.slack.com/archives/CBH302726/p1676899777428079 |
Yeah, we really shouldn't need to implement a feature that only serves to test another feature, though. 😕 @diemol do you think it would make sense for the grid to return a |
@titusfortner the current implementation doesnt need the client to know where the download directory is. Its all managed internally. I have just given the user a flexibility to specify a different base directory thats all. Everything else remains the same. Users would not need to know this directory for them to be able to download a file. |
I forgot to respond to this
The limitation with bazel is not with tests not knowing where the downloads directory is, its with tests being able to write anywhere outside of the temp directory when driven by bazel in a non standalone mode. What this means is that a node that was spun off by a bazel driven test, will NOT be able to write into the home directory since it's outside the temp folder. The flag helps get past this restriction by allowing the bazel driven test to be spin off a node whose downloads directory points to the temp directory. |
Fixes SeleniumHQ#11656 SeleniumHQ#11658 Following has been done: * Specify the default base directory into which all downloads at a node will go into via the flag “—-base-dir-downloads”. If this flag does not have a value then we default to user’s home. * Turn ON managing download folders via the flag “-—enable-manage-downloads” * Enabled support for Chrome|Edge|Firefox browsers. * File downloads will be done only in a session aware directory for a given web driver session. After session is killed, the directory gets cleaned up as well.
b646a06
to
406dea6
Compare
Silly bazel. Reviewing this is on Diego's plate along with everything else. :-/ |
Apologies for the delay on reviewing this. The PR is really large and I will need quite some time to go through it. In the future, please let's have smaller PRs whenever possible. |
I find EDIT: I do not think we need a |
I have a few comments but I due to the delays in the review I will add the changes to the PR. In general, I will change the "auto downloads" phrase to "downloads enabled", which I believe reflects better what this feature is. |
and removing out of scope logic to determine Node match and client side validations
@diemol - Thanks for taking the time to make the changes. I noticed that you have:
So we don't need this is it ? On a side note, I also noticed formatting changes. Is there a formatter that is being used by us to ensure that all code submissions adhere to the same formatting (or) is there any bazel target that I can run to ensure that the code gets auto formatted (I know that maven has such a plugin). That will ensure that my PRs adhere to the formatting asks as well. |
The formatting changes were a mistake, I only noticed after the commit. I will try to revert them. We had(have?) some IntelliJ configuration checked in the tree but it seems to not work in all cases. So I guess we will deal with it when we have loads of developers sending pull requests. I removed the check and support because this is still in beta, and this might create issues in different scenarios:
So I think adding this to the bindings it is a good idea, but we should do it later, and for all bindings. This PR should only take care about Grid changes. I hope that makes sense. |
Yep. That makes sense. I forgot about having to be backward compatible :) |
With this, it will be transparent for the user where files are written, and since we use the caches then the deletion happens when the session is closed. Also, we do not need the `--base-dir-downloads` parameter.
@diemol - I noticed that as part of this commit we got rid of the need to house the files downloaded for a given session into the user directory and moved it into temp folder. I personally dont have any opinion on the location of the downloads directory and am fine with it. Just wanted to mention that I had to work with the home directory because that was one of the asks :) I also noticed that you are having to spend more time on re-working on the PR and add additional commits. I am getting to learn more nuances of the codebase from your commits so thank u so much for that. But just that I also feel bad that I am perhaps taking up additional time from you. My apologies if it's not matching the expectations. |
@krmahadevan that was a "last minute" change. I was going through the code and I noticed we use the temp file system to store the uploads already, and most of the code was already there, so I decided to reuse it to reduce code maintenance on the Node. I understand this was one of the "requirements", but things are not written on stone here. If we find a better way to implement something that leads to being less intrusive and reduce maintenance, it should be weighted in. No need to apologize, your code was the initial step to get this done, without your contributions we would not be able to build this. Thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @krmahadevan!
* [Grid] Support auto downloads in Grid Fixes SeleniumHQ#11656 SeleniumHQ#11658 Following has been done: * Turn ON managing download folders via the flag “-—enable-manage-downloads” * Enabled support for Chrome|Edge|Firefox browsers. * File downloads will be done only in a session aware directory for a given web driver session. After session is killed, the directory gets cleaned up as well. * [grid] Renaming to manage downloads enabled and removing out of scope logic to determine Node match and client side validations * [grid] Using the temp file system utility With this, it will be transparent for the user where files are written, and since we use the caches then the deletion happens when the session is closed. Also, we do not need the `--base-dir-downloads` parameter. * [grid] Adding a cleanup executor for downloaded files * [grid] Adding e2e test and fixing bug found while adding test * [grid] Removing test --------- Co-authored-by: Diego Molina <[email protected]> Co-authored-by: Diego Molina <[email protected]>
does this support deleting files present in /session/{sessionId}/se/files ? I'm trying to make a DELETE request but it gives me 404
|
Why do you need to delete the files? Files are deleted automatically when the session stops. |
@karanjeetbirdeye its automatically taken care of. Ou dont need to be doing any explicit deletes and there is no endpoint for it as well. That explains the 404 |
actually I have requirement where in one session multiple files are downloaded, so I fetch one -> delete it -> download another -> delete it. I can loop over a list of files but their names are similar so I was looking to delete them after processing. |
We have a similar scenario where the test will repeatedly download, so being able to delete old files would be great - I know timestamps were also discussed at one point but ended up not being added. For now we're listing previous files before triggering the download, then using glob patterns to check if something matches since it will append |
thanks @ShadowLNC In our case the downloads just have random strings so it doesn't have appended values |
@diemol @krmahadevan can we have DELETE endpoint implementation for this? |
@karanjeetbirdeye please create a feature request and share as much information as possible in it. |
@krmahadevan thanks for your hard work, here is my settings, the download pdf in C://Downloads will not be auto-delete when the browser is closed, and my Chrome. driver version is 4.10.
|
@aajron this is a feature only for Selenium Grid. For questions please use StackOverflow or https://www.selenium.dev/support/ |
Hi |
Fixes #11656 #11658
Following has been done:
Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Description
Motivation and Context
Types of changes
Checklist