Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tatsuki-tanabe opened this issue Mar 7, 2025 · 1 comment
Open
Labels
bug Something isn't working

Comments

@tatsuki-tanabe
Copy link

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)
        }
    }
}
@tatsuki-tanabe tatsuki-tanabe added the bug Something isn't working label Mar 7, 2025
@tatsuki-tanabe
Copy link
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
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant