You can't click that area with webdriver unfortunately. Instead, you can set the file's downloaded folder and navigate to it.
String filePath = "file:///Users/username/Desktop/file.pdf";
webDriver.get(filePath);
Answer from Taylan Derinbay on Stack OverflowHi, if I left-click a link to download a PDF, chrome often prompts with a "Do you want to download?" or something similar, and I need to left-click a second time "Yes" or "Download" or something.
About a year ago, I discovered a keyboard shortcut where, if I hold a key, then left-click, it won't prompt the question, but it just immediately downloads the PDF to my Downloads folder.
My question โ I can't seem to repeat this single key+left click, and I can't remember what key I pressed. Does anyone know what is the key?
I need to download hundreds of PDFs (nothing illegal) and would like to avoid the question prompt and second click if at all possible, would save me literally hours. Thanks for your help!
Videos
You can't click that area with webdriver unfortunately. Instead, you can set the file's downloaded folder and navigate to it.
String filePath = "file:///Users/username/Desktop/file.pdf";
webDriver.get(filePath);
In chrome, you can use control+j to bring up downloaded files and then tab down to the recently downloaded file.
You can restore the old Alt-click "Save Link As" functionality in Firefox:
Open a new tab in Firefox. In the Firefox address space, type:
about:config
Click the "I'll be careful, I promise" prompt. Type
browser.altClickSave
in the Search space. Double-click on the browser.altClickSave line to change the value from false to true. Close the about:config tab.
Now when you Alt-click on a valid download link it will open the Save As explorer screen. All you need to do is set the correct location and press Enter. Once you set the download location, if you are downloading a lot of files into the same location, all you need to do is press enter. This will greatly speed up your download process.
I did the above process in Windows 7. It should also work in Ubuntu.
The other answers are correct for Firefox.
For Chrome it's even easier:
Option+Click (Windows: Alt+Click) saves the link-target to the download folder.
2019 Edit: Since it seems the extension below is no longer available, someone has mentioned this extension could work: Always Clear Downloads 2
Original 2012 Information: Found this Chrome extension today. It's relatively new, available since May 22, 2012:
Always Clear Downloads
A Google Chrome Extension to always clear the downloads list of all completed downloads.
User Reviews:
First extension that clears the download bar and hides it afterwards.
I have been looking for an extension that does this! Thank you. Works very well hiding the download bar after the download has completed. Saves a click.
Easier keyboard shortcuts (Windows): Ctrl+J, Ctrl+W (open "Downloads" tab and close it, which happens to also close the download bar in the original tab).
For Mac, use โ (Cmd)+Shift+J.
Until recently (perhaps a Chrome update changed things?), when a class of young novices was wrapping up, I used to walk over to each device and hit Alt + Shift + M. This shortcut used to open the Files app and take me straight to the Downloads folder within. From here, I could ask students, "Is there anything here that you meant to save to Drive?" and, if necessary, help them quickly drag the items into a Drive folder. That way, the student would not have to depend on local storage, which is a risky bet in a shared-device classroom.
Now, Alt + Shift + M continues to open the files app, but extra navigation is required to open the Downloads folder. I appreciated learning from this thread some tips about navigating within Files, although going from one shortcut to two still slows down our end-of-class wrap-up routine.
Control + J is fine if the answer to "Is there anything here that you meant to save to Drive?" is "no," but if the answer is "yes" more work needs to be done before the items can be dragged into Drive. Also, Control + J conflicts with some other keyboard shortcuts (in Reddit, for example).
I am not the device administrator, so I do not have direct control over things that get installed or scripts that get run, so I would be thrilled if a one-and-done keyboard shortcut still exists, but as a backup plan I would be happy to hear any fancier strategies with settings or extensions that could address this issue.
Thanks in advance for any tips!