-
Notifications
You must be signed in to change notification settings - Fork 103
Allow downloads when headless, via Chrome Command #33
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
Allow downloads when headless, via Chrome Command #33
Conversation
@Windos is there no chrome_options object/way that will do the same thing ? |
No that I'd found. I did wonder and do a quick Google... but could well have missed something. |
@Windos can you check if the code below works for you ?
|
Unfortunately, no luck on that. I also tried (and it didn't work): if($Headless){
$Chrome_Options.AddUserProfilePreference('Page.setDownloadBehavior', @{'behavior' = 'allow'; 'downloadPath' = $DefaultDownloadPath.FullName})
} No errors or anything when making those changes, just no download. |
@adamdriscoll @Windos this PR also has a bunch of formatting changes and as more people start working on the project we should probably discuses some form of standard for the project's code formatting so we don't end up with new formatting all the time.
PS. Thank you very much for the PR and contribution!! |
I can go back and revert those formatting changes, I'll just need to remember to turn off the formatter when I send through future PRs lol. My understanding of specifying it a second time is that you're granting permission to download to that folder. In theory if it tries to download to any other folder it'll fail. I thought the script continuing was a standard thing, headless or not? I'm sure that's why I've got a sleep after each download to make doubly sure it's on disk. I am only dealing with tiny files though, not large ones. It does make sense as far as browser operation goes, you can start a download and then continue off onto other pages, etc. while it finishes. It's just a pain if you're wanting to act on those files right away. |
Looks good. Thanks!! |
I've been using this module to automate the bulk download of CSV files from our RMM system (because their API is rubbish!), and today went to try headless with the beta for when it's running on a schedule.
Unfortunately, downloading and headless is disabled by default for security.
Luckily, from some Chromium 62 build and onward it's possible to enable it.
This PR executes a Chrome Command, allowing downloads to the
DefaultDownloadPath
if both the path and-Headless
has been specified.p.s. I'm sorry about all the misc other small edits in the file. VS Code cleaned up a bunch of trailing white space and I didn't spot it in the diff.