Skip to content
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

Prompt-less file downloads on Chrome no longer works with image 3.141.59-20200719 and above. #1095

Closed
testphreak opened this issue Aug 6, 2020 · 5 comments

Comments

@testphreak
Copy link
Contributor

💥 Regression Report

Starting with node-chrome:3.141.59-20200719 downloading a file in Chrome bring up a modal/prompt asking for the save location. This error does not occur in node-chrome:3.141.59-20200525 and lower. Not sure if it coincides with a few other changes in the 3.141.59-20200719 image. Chrome was also bumped from v83 to v84. But when I test locally with v84 I can still do silent downloads.

Chrome options that enable prompt-less downloads -

Map<String, Object> chromePrefs = new HashMap<>();
ChromeOptions options = new ChromeOptions();
chromePrefs.put("download.default_directory", downloadPath);
chromePrefs.put("download.prompt_for_download", false);
options.setExperimentalOption("prefs", chromePrefs);
MutableCapabilities chromeCapabilities = new MutableCapabilities();
chromeCapabilities.setCapability(ChromeOptions.CAPABILITY, options);

Last working version

Worked up to version: 3.141.59-20200525

Stopped working in version: 3.141.59-20200719

To Reproduce

Steps to reproduce the behavior:

Expected behavior

I should be able to download a file without the save-as prompt/modal from a web page in Chrome inside a running docker-selenium container.

Environment

OS:
Docker-Selenium image version: node-chrome:3.141.59-20200719
Also provide the docker image id: sha256:1b785fed01399256af34748d77dbb4853646ccafe2d5506f75d10ad3f97e663c

Docker version: 18.09.3, build 774a1f4
Docker-Compose version (if applicable):
Exact Docker command to start the containers (if using docker-compose, provide
the docker-compose file as well):

I use a Docker Swarm setup which is a little more involved. Will be happy to share commands if absolutely needed for troubleshooting.

@ghost ghost added the needs-triaging label Aug 6, 2020
@diemol
Copy link
Member

diemol commented Aug 7, 2020

@testphreak is it possible to have a complete script to reproduce the issue? I don't have a website where I can download something.

@testphreak
Copy link
Contributor Author

testphreak commented Aug 17, 2020

@diemol sorry it took me a few days to get back on this issue. I was able to dig deeper into the issue and figure out the problem. The failed downloads are directly due to the change made by @srguglielmo to use a numeric user instruction in Dockerfiles. The issue had nothing to do with Chrome specifically as I previously thought. I suspect pretty soon, others in this community who download files, like here, and are still on older versions of the images will start seeing issues as they update to the latest.

The downloads fail due to insufficient permissions when files are saved on mounted volumes and the hosts are Linux. In my case the volume was mounted as user ubuntu with uid/gid 1000:1000. The files in the latest Docker images are run inside containers with uid/gid 1200:1201 causing the errors. Downloads worked on MacOS but not on Ubuntu which made the issue confusing. While I realize the change was made to adhere to best practices; due to this long standing issue, mounting of volumes by users other than root is still not supported by Docker.

Posting my solutions here, for when others run into this issue -

  1. Quick-fix/workaround: Set the User inside the container as 0 (root) which downloads the file with owner/group as root. Next chown/chgrp the files to your host user, in my case ubuntu, to do some post-processing on those files.
  2. Ideal fix: Create a new user and group on the Linux host called seluser with user id 1200 and group 1201 to match the uid and gid set in the latest Docker images. Going with this option is a bit more involved, but is cleaner and eliminates the need to chown/chgrp the files or run container as root.

@bravier
Copy link

bravier commented Sep 2, 2020

@testphreak thanks a ton for opening this issue, digging into it and proposing solutions!

I can confirm downloads were not working anymore since 3.141.59-20200719 but your solution works fine!

@diemol
Copy link
Member

diemol commented Oct 26, 2021

Thank you @testphreak for providing all this information. I just added some troubleshooting notes in the README for other folks bumping into the same situation.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants