Reputation: 159
I had some trouble using Selenide's download function. This is my flow:
So basically the new tab is opened in Chrome PDF Viewer. I tried to click on the hidden download button in the new tab but no luck. My thinking got me to the idea of when I click that button, this new tab shouldn't open, the download should start. That would mean settings some Configuration preferences like I did below:
Configuration.browserCapabilities = new DesiredCapabilities();
Configuration.browserSize = "1920x1080";
Configuration.fileDownload = FileDownloadMode.FOLDER;
Configuration.downloadsFolder = "./src/pdfs";
Configuration.proxyHost = "30.40.34.82";
Configuration.proxyPort = 8080;
Configuration.proxyEnabled = true;
Configuration.fileDownload = FileDownloadMode.PROXY;
Configuration.browserCapabilities.setCapability("plugins.always_open_pdf_externally", true);
Configuration.browserCapabilities.setCapability("download.prompt_for_download", false);
Configuration.browserCapabilities.setCapability("pdfjs.disabled", true);
The problem is that, this still opens new tab, and I get no such element found
File file = applicationList.printButton.download(30000);
Upvotes: 0
Views: 1655
Reputation: 510
Why do you first set Configuration.fileDownload
to FOLDER
and then to PROXY
? No need to set it twice.
I think you cannot download the file via PROXY
because links of type blob:
don't fetch file content from the server.
I think you can just remove all these lines:
Configuration.proxyHost = "30.40.34.82";
Configuration.proxyPort = 8080;
Configuration.proxyEnabled = true;
Configuration.fileDownload = FileDownloadMode.PROXY;
Configuration.browserCapabilities.setCapability("plugins.always_open_pdf_externally", true);
Configuration.browserCapabilities.setCapability("download.prompt_for_download", false);
Configuration.browserCapabilities.setCapability("pdfjs.disabled", true);
Selenide method FOLDER
should download the file without all these tricky settings.
Upvotes: 1
Reputation: 1
Try it
System.setProperty("chromeoptions.prefs", "plugins.always_open_pdf_externally=true")
Upvotes: 0