To resolve the PDF download issue in Microsoft Edge Chromium with Katalon Studio, configure these browser options and capabilities:
1. Essential Edge Options for PDF Downloads
groovy
import org.openqa.selenium.PageLoadStrategy
import org.openqa.selenium.edge.EdgeOptions
import com.kms.katalon.core.webui.driver.DriverFactory
// Set download directory (use absolute path)
String downloadDir = "C:\\Your\\Download\\Path"
EdgeOptions edgeOptions = new EdgeOptions().tap {
// Browser settings
setPageLoadStrategy(PageLoadStrategy.NORMAL)
addArguments("--start-maximized")
addArguments("--disable-notifications")
addArguments("--disable-extensions")
// PDF download preferences
Map<String, Object> prefs = new HashMap<>()
prefs.put("download.default_directory", downloadDir)
prefs.put("download.prompt_for_download", false)
prefs.put("plugins.always_open_pdf_externally", true) // Critical for PDFs
prefs.put("safebrowsing.enabled", true)
// Set preferences
setExperimentalOption("prefs", prefs)
}
// Apply options when starting browser
WebUI.openBrowser(
"",
[],
edgeOptions,
DriverFactory.getWebDriverPreferences()
)
2. Required Capabilities in Katalon Settings
Add these to your execution.properties:
text
# Edge-specific capabilities
edgeOptions.args=["--start-maximized", "--disable-notifications"]
edgeOptions.prefs={"download.default_directory":"C:\\Your\\Download\\Path", "download.prompt_for_download":false, "plugins.always_open_pdf_externally":true}
edgeOptions.experimentalOption={"prefs": {"download.default_directory":"C:\\Your\\Download\\Path","download.prompt_for_download":false}}
3. Additional Verification Steps
- Ensure the download directory:
- Already exists
- Has write permissions
- Path uses double backslashes (
C:\\Downloads)
- Add these steps after clicking download:
groovy
// Wait for download to complete
WebUI.delay(10)
// Verify file exists
File downloadedFile = new File("$downloadDir\\yourfile.pdf")
assert downloadedFile.exists() : "PDF download failed"
4. Common Fixes for Edge-Specific Issues
- EdgeDriver Compatibility:
- PDF Viewer Policy:
Add this browser argument to force downloads:
groovy
edgeOptions.addArguments("--force-pdf-download")
- Network Configuration:
Disable Edge’s built-in PDF viewer completely:
groovy
edgeOptions.addArguments("--disable-pdf-plugin")
Troubleshooting Tips:
- Check Edge’s internal PDF viewer status:
groovy
WebUI.executeJavaScript("return navigator.plugins[0].filename", null)
// Should return "internal-pdf-viewer"
- Add download verification logic:
groovy
int timeout = 30
while (timeout > 0) {
if (new File("$downloadDir\\yourfile.pdf").exists()) break
WebUI.delay(1)
timeout--
}
assert timeout > 0 : "Download timed out"
- If using Test Case/Suite hooks:
groovy
@BeforeTestCase
def setupEdgeDownloads() {
// Apply the same Edge options here
}
Note: Edge requires absolute paths for download directories. The plugins.always_open_pdf_externally preference is crucial for triggering downloads instead of browser previews. Monitor Edge’s download manager page (edge://downloads/) during execution for debugging.