javaselenium-webdrivermicrosoft-edgeheadless

Java Selenium - How to remove download menu from popping up with the new headless mode?


does anyone knows what is the argument to set to remove the download menu from popping up after a download is completed in Microsoft Edge using the new headless mode? My selenium program requires Microsoft Edge as the webdriver, hence I can't use Chrome or Firefox webdrivers. But if you guys have any idea, please let me know, thank you!

Have looked everywhere for a list of the arguments that I could set, but could not find any related to the disabling of the download menu from popping up.

Edit to include example code:

The following is an example code. In this example, the url used is the download link for the latest Microsoft Edge webdriver:

public static void main(String args[]) {
    System.setProperty("webdriver.edge.driver","src/main/resources/msedgedriver.exe");

    EdgeOptions options = new EdgeOptions();
    options.addArguments("headless=new");
    options.addArguments("--window-size=1920,1080");
    options.addArguments("--start-maximized");
    options.addArguments("--inprivate");
    options.addArguments("--disable-popup-blocking");
    // options.addArguments("___argument to disable download menu___");
        
    EdgeDriver driver = new EdgeDriver(options);
    driver.get("https://msedgedriver.azureedge.net/115.0.1860.0/edgedriver_win64.zip");
}

2nd Edit to include screenshot Screenshot of Download Popup


Solution

  • I'm unable to have this browser UI when I'm in the new headless mode, but if you want to prevent that downloads menu, you can try the following code:

        Map<String, Object> prefs = new HashMap<String, Object>();
        prefs.put("browser.show_hub_popup_on_download_start", false);
        options.setExperimentalOption("prefs", prefs);