Skip to content

driver.getWindowHandles() does not respond after file download #196

Description

@iamvishwa01
  1. Launch the application and log in.

  2. Navigate to a specific screen that opens in a new window, where multiple file download links are available.

  3. Before clicking the download button, driver.getWindowHandles() correctly returns a total of 2 windows.

Set s = driver.getWindowHandles();
System.out.println(s.size()); // Returns 2
This works as expected before initiating the file download.

  1. Upon clicking the first download link, a new download window opens, and the file starts downloading.

  2. However, when attempting to retrieve all window handles again using driver.getWindowHandles(), an error occurs.
    Log: org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException
    Build info: version: '4.29.0', revision: '5fc1ec94cb'
    System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.6'
    Driver info: org.openqa.selenium.edge.EdgeDriver
    Command: [5b5a3682c54d8cc33f465c4450dc9bac, getWindowHandles {}]
    Capabilities {acceptInsecureCerts: false, browserName: MicrosoftEdge, browserVersion: 134.0.3124.93, fedcm:accounts: true, ms:edgeOptions: {debuggerAddress: localhost:61296}, msedge: {msedgedriverVersion: 134.0.3124.93 (a9facff5fd6c..., userDataDir: C:\Users\Admin\AppData\Loca...}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: windows, proxy: Proxy(), se:cdp: ws://localhost:61296/devtoo..., se:cdpVersion: 134.0.3124.93, setWindowRect: true, strictFileInteractability: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true}
    Session ID: 5b5a3682c54d8cc33f465c4450dc9bac

Driver Capabilities used:
else if (browser.equalsIgnoreCase("edge")) {
Map<String, Object> prefs = new HashMap<>();
prefs.put("download.prompt_for_download", false);
prefs.put("download.default_directory", Hooks.downloadPath);
prefs.put("safebrowsing.enabled", false);
prefs.put("safebrowsing.disable_download_protection", true);
EdgeOptions options = new EdgeOptions();
options.setExperimentalOption("prefs", prefs);
options.addArguments("--allow-running-insecure-content");
options.addArguments("--ignore-certificate-errors");
options.addArguments("--disable-popup-blocking");
ds.setAcceptInsecureCerts(true);
System.setProperty("webdriver.chrome.driver", "C:\Users\Admin\Downloads\edgedriver_win64\msedgedriver.exe");
tldriver.set(new EdgeDriver(options));
DevTools devTools = ((EdgeDriver) tldriver.get()).getDevTools();
devTools.createSession();
devTools.send(Browser.setDownloadBehavior(
Browser.SetDownloadBehaviorBehavior.ALLOW,
Optional.empty(),
Optional.of(Hooks.downloadPath),
Optional.of(true)
));
}

Activity

  1. RumikaHamamoto commented on Jun 16, 2025

    @RumikaHamamoto

    Hello,
    Chiming in to say that our team is also affected by this issue. We'd like to share some specific behavior we observed, which may help with debugging.

    Here is the sequence of events we confirmed on our end:

    1. After a file download, calling driver.getWindowHandles() causes the driver to hang and become unresponsive.
    2. After waiting for approximately 10 minutes, the driver.getWindowHandles() method eventually returns a response.
    3. However, the returned value contains 4 window handles: the 2 original ones, plus two new, unexpected ones.
    4. When we then attempt to access the currentURL or title of the last handle (the fourth one), the driver becomes unresponsive again.
    5. This time, the driver did not recover or return a response, even after waiting for 90 minutes.

    We hope this information is useful.
    We would be very grateful if you could share any new information or progress on this matter.
    Thank you for your attention to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions