How do I get around the Download popup in Edge during an automated test

Stephen 0 Reputation points
2025-11-17T14:59:25.0666667+00:00

I have a test framework in C# with Selenium and XUnit. There are a number of tests that execute sequentially for a webpage. The first of these tests clicks on a link in the page that downloads a file. The test checks for the downloaded file and then deletes it. The test works perfectly, but the Download popup remains displayed in the top-right corner of the screen, thus causing the following tests to time out unless I manually click sopmewhere on the screen to close the download popup. I've tried several different EdgeOptions when setting up the EdgeDriver, but none of them work. Here is my current 'case' settings for Edge:

case "edge": 
    EdgeOptions edgeOptions = new();
    edgeOptions.AddArgument("--start-maximized");
    edgeOptions.AddArgument("--disable-features=DownloadBubble");
    edgeOptions.AddArgument("--disable-notifications");
    edgeOptions.AddArgument("--disable-infobars");
    edgeOptions.AddArgument("--no-download-notification");
    edgeOptions.AddArgument("--disable-dev-shm-usage");
    edgeOptions.AddArgument("--disable-features=msEdgeEnableNurturingFramework");
    edgeOptions.AddArgument("--disable-blink-features=AutomationControlled");
    edgeOptions.AddExcludedArgument("enable-automation");
    edgeOptions.PageLoadStrategy = PageLoadStrategy.Normal;
    var tempProfileDir = Path.Combine(Path.GetTempPath(), "EdgeProfile_" + Guid.NewGuid());
    edgeOptions.AddArgument($"--user-data-dir={tempProfileDir}");
    edgeOptions.AddUserProfilePreference("download.prompt_for_download", false);
    edgeOptions.AddUserProfilePreference("safebrowsing.enabled", true);
    return new EdgeDriver(edgeOptions);

How can I get Selenium to ignore this pop-up and remain focused on the main page so that I can navigate it and click on other elements?

Microsoft Edge | Website issues | Windows 10
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. John Carl Nazario 8,530 Reputation points Independent Advisor
    2025-11-17T15:31:44.19+00:00

    Hi Stephen, first, the Edge download popup is outside the DOM, so Selenium can’t dismiss it directly. Disabling it with --disable-features=DownloadBubble used to work, but this flag is deprecated in recent Edge versions. Second, configure Edge to auto-download without showing the bubble by setting preferences like download.default_directory, download.prompt_for_download = false, and profile.default_content_settings.popups = 0 in EdgeOptions. Third, if the popup still appears, try running Edge in headless or kiosk mode using --headless=new and --disable-popup-blocking to suppress UI overlays. Last, if you need full UI but want Selenium to ignore the popup, switch focus back to the main window with driver.SwitchTo().Window(driver.CurrentWindowHandle) or use JavaScript to click on the page body with ((IJavaScriptExecutor)driver).ExecuteScript("document.body.click();");.
    If this helps, please mark the answer as accepted so others can find it too.

    -Carl

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.