Katalon Studio v5.8 - It's time for the all-new API testing experience
Pranay sapkale
Katalon Apprentice
08/09/2018

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
Upvote
Quote

Comments

  • Marek Melocik
    Katalon Expert
    08/09/2018
    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.
    Best Answer
    Upvote
    Quote
  • Pranay sapkale
    Katalon Apprentice
    08/09/2018
    Hi,

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

    Thanks,
    Pranay
    Upvote
    Quote
  • Pranay sapkale
    Katalon Apprentice
    08/09/2018
    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
    Upvote
    Quote
  • Marek Melocik
    Katalon Expert
    08/09/2018
    Hello, looks like imports are missing. Either press Ctrl-Shift-O to update imports or paste these lines:

    import org.openqa.selenium.WebDriver
    import org.openqa.selenium.chrome.ChromeDriver
    import org.openqa.selenium.chrome.ChromeOptions
    
    import com.kms.katalon.core.webui.driver.DriverFactory
    Upvote
    Quote
  • Pranay sapkale
    Katalon Apprentice
    08/09/2018
    Code is running but it is not opening Save as popup. It is opening new chrome browser tab in different chrome window.
    Upvote
    Quote
  • Marek Melocik
    Katalon Expert
    08/09/2018
    That's weird, it works for me. Did you try to download something else? 
    Upvote
    Quote
  • Pranay sapkale
    Katalon Apprentice
    08/10/2018
    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.
    Upvote
    Quote
  • Marek Melocik
    Katalon Expert
    08/10/2018
    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)?
    Upvote
    Quote
  • Pranay sapkale
    Katalon Apprentice
    08/10/2018
    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
    Upvote
    Quote
  • Marek Melocik
    Katalon Expert
    08/10/2018
    Can I see your test case? And, if possible, also HTML element you click to download your file.
    Upvote
    Quote
  • Pranay sapkale
    Katalon Apprentice
    08/10/2018
    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
    Upvote
    Quote
  • Marek Melocik
    Katalon Expert
    08/10/2018
    I found one more chrome option which may help you. Add this one:

    chromePrefs.put("plugins.always_open_pdf_externally", true)
    Upvote
    Quote
  • Pranay sapkale
    Katalon Apprentice
    08/10/2018
    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?
    Upvote
    Quote
Sign In or Register to comment.
Not the answer you're looking for? Consider subscribing to Business support.