How to down load an embeded PDF document from Edge Browser

Hi All, I need to download a pdf document from Edge Browser. I tried with many options in script level as well as Katalon Studio level.

But I was not able to download the document.

Steps:

  1. Click on View PDF Summary button
  2. PDF document opens in another window.
  3. Unable to click on ‘Save’ button, could be due to another window.

I used following settings in Katalon Studio: but no luck.

Can anyone provide me some suggestions. Thanks!

Hi Thushar

this usually happens because the PDF Save button in Edge belongs to the browser’s built-in PDF viewer, not the web page DOM. Because of that, Katalon/Selenium often cannot click it reliably.

Recommended approach:

  1. Configure Edge to download PDFs instead of opening them in the browser viewer
  2. Click View PDF Summary
  3. Verify the PDF is saved in the download folder

Example setup:

groovy
import org.openqa.selenium.edge.EdgeDriver
import org.openqa.selenium.edge.EdgeOptions
import com.kms.katalon.core.webui.driver.DriverFactory

Map prefs = new HashMap()
prefs.put('download.default_directory', 'C:\\Downloads\\Katalon')
prefs.put('download.prompt_for_download', false)
prefs.put('plugins.always_open_pdf_externally', true)

EdgeOptions options = new EdgeOptions()
options.setExperimentalOption('prefs', prefs)

DriverFactory.changeWebDriver(new EdgeDriver(options))

Why this works:

  • plugins.always_open_pdf_externally = true tells Edge/Chromium not to open the PDF in the internal viewer
  • Instead, the PDF should download directly

If the PDF still opens in a new tab, then the better fallback is:

  • switch to the new tab
  • get the PDF URL
  • download it directly using request-based code with the current session/cookies

I would avoid trying to automate the PDF viewer toolbar (Save, Print, etc.) because those controls are browser UI and are usually flaky in automation.

let us know if that helps

The safest Katalon approach is to avoid clicking the PDF viewer’s Save button and instead make Edge download PDFs directly.

What to do

  • Set Edge to always download PDF files or open PDFs externally, so the embedded viewer never appears.

  • Then click View PDF Summary and verify the file appears in your download folder.

  • If the PDF still opens in a new tab, capture the PDF URL and download it directly rather than automating the browser toolbar.

Katalon/Edge config idea

Use Edge preferences like these so PDFs download instead of opening in the built-in viewer:

prefs.put('download.default_directory', 'C:\\Downloads\\Katalon')
prefs.put('download.prompt_for_download', false)
prefs.put('plugins.always_open_pdf_externally', true)

That last setting is the important one because it tells Edge not to use its internal PDF viewer

Why this works

The Save button in the embedded PDF viewer is browser UI, not normal page DOM, so Selenium/Katalon often can’t click it reliably.
That’s why direct download is much more stable than trying to automate the viewer toolbar.

Practical fallback

If the PDF opens in a separate tab anyway, switch to that tab, copy the PDF URL, and download the file with authenticated session handling instead of UI clicks.

Though @nghi.phan and @dineshh have already given the right answers and I think your issue will be resolved by either of those solutions.
But in case if those solutions are also not working, try Native keystroke route, I have used on couple of places and it works.
Try using java.awt.Robot or Sikuli method, this works because Robot operates at the OS input level, not through WebDriver — it’s a legitimate, commonly-used pattern for exactly this class of problem.

So just simply shift to the new tab and then go for robot method ( just like the way we do to save the pdf in our laptop)

Thanks nghi.phan for your response.

I still could not download the pdf file to the target folder, don’t know if this is the application. With similar settings in Desired Capabilities, I was able to download the pdf file in another application(GW.) I tried changing the Edge browser PDF settings also but didn’t work.

Other issue is when I click the PDF link it opens in another window frame rather another tab. Not able to use switchtoWindowIndex.