Chrome Capabilities

Hi,

Can anyone has idea about chrome capabilities which allows window Save as popup enable through script?

When i am trying to download pdf file from chrome it directly get downloaded. I want that Save As popup so I can automate that.

Thanks,
Pranay

Hi,

to enable download prompt, use this code:

Map chromePrefs = new HashMap<>()chromePrefs.put("download.prompt_for_download", true)System.setProperty("webdriver.chrome.driver", DriverFactory.getChromeDriverPath())ChromeOptions options = new ChromeOptions()options.setExperimentalOption("prefs", chromePrefs)WebDriver driver = new ChromeDriver(options)

But I am afraid that neither Katalon nor Selenium is able to handle such popups as download prompt. What do you want to achieve? If you want custom download location, you can use

chromePrefs.put("download.default_directory", "C:\\whatever")

and set download prompt to false.

2 Likes

Hi,

With selenium i was able to handle window popup. Trying with same method in Katalon.

Thanks,
Pranay

I tried your code but it is not working. Giving me error as -

file:/C:/Users/sapkpra/Katalon%20Studio/FrameWork%20QS%20-%20Copy/Scripts/pdfDownload/Script1533622244281.groovy: 52: unable to resolve class ChromeOptions

@ line 52, column 25.

ChromeOptions options = new ChromeOptions()

                       ^

file:/C:/Users/sapkpra/Katalon%20Studio/FrameWork%20QS%20-%20Copy/Scripts/pdfDownload/Script1533622244281.groovy: 54: unable to resolve class WebDriver

@ line 54, column 11.

WebDriver driver = new ChromeDriver(options)

         ^

file:/C:/Users/sapkpra/Katalon%20Studio/FrameWork%20QS%20-%20Copy/Scripts/pdfDownload/Script1533622244281.groovy: 54: unable to resolve class ChromeDriver

@ line 54, column 20.

WebDriver driver = new ChromeDriver(options)

                  ^  

Thanks,
Pranay

Hello, looks like imports are missing. Either press Ctrl-Shift-O to update imports or paste these lines:

import org.openqa.selenium.WebDriverimport org.openqa.selenium.chrome.ChromeDriverimport org.openqa.selenium.chrome.ChromeOptionsimport com.kms.katalon.core.webui.driver.DriverFactory

Code is running but it is not opening Save as popup. It is opening new chrome browser tab in different chrome window.

That’s weird, it works for me. Did you try to download something else?

I am trying to download pdf file. While running its open new tab and just close current tab. It does not open Download popup and open new browser.

I am not sure if I understand. You want to download PDF file, but when you hit a link to view/download, a new tab is opened with PDF content (PDF is directly opened in a browser)?

No actually its blank tab opened. I want Save As Popup to get opened in new tab. But currently its not opening. It closes browser and open new browser tab

Can I see your test case? And, if possible, also HTML element you click to download your file.

Due to company policy i can’t share you test case. But can you share me your sample script where you are downloading pdf and you get Save As dialogue box open? It will really help me to get what i am missing

I found one more chrome option which may help you. Add this one:

chromePrefs.put("plugins.always_open_pdf_externally", true)

It’s also not working. save as Popup is not getting opened in chrome. pdf directly get downloaded… Can you share your code which is working for you?

Hi everybody.

I tried to do something similar to the camera permissions in Chrome. Did somebody had this problem and solve it using capabilities? Maybe start without ask for camera and mic permissions.

Thanks