Opening a PDF tab generates two windowhandles and an error occurs · Issue #191 · MicrosoftEdge/EdgeWebDriver · GitHub
Skip to content

Opening a PDF tab generates two windowhandles and an error occurs #191

Open

Description

@tatsuki-tanabe

What Happen

Two windowhandles are generated when a PDF tab is opened, and an error occurs when an operation is performed on the untethered windowhandle.

since when?

This has not occurred on 133.0.3027.0 EdgeDriver.
It occurs with 133.0.3028.0.

The same event is also occurring on the ChromeDriver side, for more details, please see
https://issues.chromium.org/u/2/issues/396611138?pli=1

What are you having trouble with?

A large number of test cases related to the pdf of an automated testing infrastructure based on selenium cannot pass due to this issue.
At this time we are able to work around this by using the 133.0.3027.0 driver to operate the 134 browser.
We hope that this issue will be resolved before the release of the 135 browser, as it will be impossible to work around once the 135 browser is released.
Please help us with any investigation that is needed and we will do our best to assist you.
Thank you.

reproduction script

driver.windowHandles determines whether the number of output handles is two or one.

package com.asirrera

import org.openqa.selenium.WebDriver
import org.openqa.selenium.edge.EdgeDriver
import org.openqa.selenium.edge.EdgeOptions
import java.nio.file.Paths

class WebTest {

    companion object {
        private lateinit var driver: WebDriver
        private val testPdfPath =
            Paths.get("C:\\driver-test\\test.pdf").toAbsolutePath()
                .toString()

        private val driverPath =
            "C:\\driver-test\\driver\\edgedriver_win64_3028\\msedgedriver.exe" 

        @JvmStatic
        fun main(args: Array<String>) {
            System.setProperty("webdriver.edge.driver", driverPath)
            val options = EdgeOptions().apply {
//                setBinary(chromeBetaPath)
                addArguments("--disable-gpu")
                addArguments("--no-sandbox")
                addArguments("--disable-dev-shm-usage")
            }
            driver = EdgeDriver(options)
            driver.get("$testPdfPath")
            Thread.sleep(2000)
            println(driver.windowHandles)
            println(driver.windowHandle)
            driver.switchTo().window(driver.windowHandles.last()).close()
            println("OK")
            Thread.sleep(2000)
        }
    }
}

Activity

  1. tatsuki-tanabe commented on Mar 10, 2025

    @tatsuki-tanabe
    Author

    I can work around the ChromeDriver issue by fixing it and building it yourself. But I can't rebuild the EdgeDriver because it's not publicly available.
    Does anyone have any good ideas?

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