Skip to content

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

Open
@iamvishwa01

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)
));
}

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