1

So I read all the other stackoverflow topics about this, none of the solutions worked for me so lets see if someone can help me.

I need to verify a download (csv) from an export button in chrome(driver) without a link but js. I can target the btn, click to start the download but then the chrome popup promp comes up which I cant target anymore. Not without switch to alert or other frame or window etc etc.

My chrome options are all correct and I've set accept_ssl_cert as well. I dont have any clue what to do. I am sure these options are correctly transfered since I can change the download directory and it changes in the prompt. In the automated chrome webdriver the box is also unchecked with 'ask where to save each file before downloading' however when I manually try to download something in here the prompt does indeed come up...

chromedriver preferences:

 download.prompt_for_download=false
 directory_upgrade=true 
 download.default_directory=/home/ 
 profile.default_content_settings.popups=0 
 plugins.always_open_csv_externally= true

anyone has an idea why this download popup always comes up? Or how to target it? Or maybe a different way to verify the download is started/can be stared/is downloading?

6
  • 1
    can you screen shot of the popup and also link to any site where we can try the same behavior
    – PDHide
    Nov 18, 2020 at 21:00
  • sure.. any of these files at the-internet.herokuapp.com/download and screenshot: i.imgur.com/DATTLbR.png
    – thomarkey
    Nov 19, 2020 at 0:40
  • Can you add your code also
    – PDHide
    Nov 19, 2020 at 0:41
  • my code is quite difficult because its super nested in a framework. but my driverprovider sets up my selenium chromedriver perfectly with the above preferences.
    – thomarkey
    Nov 19, 2020 at 0:43
  • There are different ways to set preference just add that could which you use to pass preference to chrome driver
    – PDHide
    Nov 19, 2020 at 0:45

1 Answer 1

1

This worked for me in Windows:

ChromeOptions options = new ChromeOptions();
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("download.default_directory", "D:\\temp");
prefs.put("download.prompt_for_download", false);
options.setExperimentalOption("prefs", prefs);
driver.set(new ChromeDriver(options));

you should use setexperimentalOptions, and in Chrome87 ask for the prompt is turned off by default I guess.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.