Skip to content

GetWindows doesn't respond after downloading #193

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
Okamo1029 opened this issue Mar 12, 2025 · 4 comments
Open

GetWindows doesn't respond after downloading #193

Okamo1029 opened this issue Mar 12, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@Okamo1029
Copy link

If you do the following, it will not respond.
This occurs from version 133 onwards.
msedgedriver - Edge version combination
134 - 134: Occurs
133 - 133: Occurs
132 - 133: Does not occur
chromedriver - Chrome combinations, both 133 and 134, work normally.
(1) Start msedgedriver.exe
(2) Open a browser
(3) Navigate to the following site (any site will do)
https://forest.watch.impress.co.jp/library/software/7zip/
(4) Click the download button manually
(5) Wait for the download to complete
(6) This occurs once every few times when GetWindows is called
http://localhost:xxxxx/session/$sessionid/window/handles
(7) If this does not occur, manually return to the previous page and repeat steps (4) to (6).

Note: This is more likely to occur if FindElement or similar is called between steps (4) and (6).

Attached is the log file.

EdgeDriver01A.log
EdgeDriver02A.log

@Okamo1029 Okamo1029 added the bug Something isn't working label Mar 12, 2025
@Okamo1029
Copy link
Author

I am scraping internal company web pages. Since I cannot share the internal pages, I used the 7zip download page as an example in my initial post, but this occurs infrequently. It always occurs on the internal pages.

I have attached the log from scraping the internal pages. The file is named EdgeDriver03A.log. The internal pages perform download operations in a popup window from the main page. After the final AcceptAlert, the download starts, and once the file extension is no longer "crdownload," I call SwitchToWindow, but it times out.

EdgeDriver03A.log

@guangyuexu
Copy link

Hi @Okamo1029 , how often do you get this issue? I tried to manually test the issue with Edge 134.0.3124.66 but cannot repro the issue. I also created a test app and ran 20+ times, still cannot repro:

`using OpenQA.Selenium;
using OpenQA.Selenium.Edge;

namespace WebdriverGetWindowNotResponding
{
internal class Program
{
private static void GetWindowInfo(IWebDriver driver)
{
int tabCount = driver.WindowHandles.Count;

        for (int i = 0; i < tabCount; ++i)
        {
            Console.WriteLine(string.Format("GetWindowInfo:driver.WindowHandles[{0}]:", i) + driver.WindowHandles[i]);
        }

        Console.WriteLine(string.Format("GetWindowInfo WindowCount={0} CurrentWindowHandle:{1}",
            driver.WindowHandles.Count, driver.CurrentWindowHandle));

    }

    static void Main(string[] args)
    {
        EdgeOptions opts = new EdgeOptions();
        opts.AddArgument($"--app=https://forest.watch.impress.co.jp/library/software/7zip/");
        opts.BinaryLocation = "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe";

        var edgeDriverService = EdgeDriverService.CreateDefaultService();
        //edgeDriverService.EnableVerboseLogging = true;

        var driver = new EdgeDriver(edgeDriverService, opts, TimeSpan.FromMinutes(2));

        var url = "/library/software/7zip/download_11607.html";
        var download = driver.FindElement(By.XPath("//a[@href=\"/library/software/7zip/download_11607.html\"]"));
        download.Click();

        GetWindowInfo(driver);
        Thread.Sleep(5000);
        GetWindowInfo(driver);

        driver.Close();
        driver.Quit();
    }
}

}`

@Okamo1029
Copy link
Author

Thank you guangyuexu for your prompt reply.
I understand the issue of frequency of occurrence. I will search for pages and procedures that frequently occur on public web pages.

This issue occurs 100% on our company's internal web pages.

As a supplement, the scraping tool is created using the following TinySeleniumVBA and Excel VBA. This is to distribute it to many people without requiring installation: https://github.com/uezo/TinySeleniumVBA/blob/main/README.ja.md

@Okamo1029
Copy link
Author

Thank you guangyuexu.
I have created a simple page that replicates the screen transitions of our company's internal web page.
The file is named docroot.zip.
We have confirmed that the issue can be reliably reproduced on this page. (We used the command "python -m http.server 8000" to run the web server.)
Please extract the contents to an appropriate folder.
If Python 3 is already installed, you can start the server using svexec.bat.

docroot.zip

Here are the steps to reproduce the issue:

(1) Display "http://localhost:8000/main01.html"
(2) Click the "sub window" button to display the popup window
(3) Transition between windows and iframes
(4) Click the "download" button to display the confirmation dialog
(5) Click the OK button to download
(6) Wait for a few seconds (important)
(7) Transition between windows (the issue occurs here)

Below is the actual VBA code. I'm not familiar with other languages, so I'll write it in VBA code. Sorry.

LogFile05.log


Dim strW01 As String 'Variable to store window ID
Dim strW02 As String 'Variable to store window ID
Dim strMsg As String 'Variable to store alert message
Dim oS As WebElement 'WebElement object
Dim nWin As Long 'Number of windows

'Open the browser
Driver.OpenBrowser

'Navigate to the target page
Driver.Navigate "http://localhost:8000/main01.html"

'Get the window ID
strW01 = Driver.GetCurrWindowHandle
'Get the current number of windows
nWin = Driver.GetWindowCount

'Get the object of the "sub window" button
Set oS = Driver.FindElement(By.ID, "mbtn")
'Click the button
oS.Click

'Set the newly popped-up window as the target
Call Driver.SwitchLatestWindow(nWin)

'Get the window ID
strW02 = Driver.GetCurrWindowHandle

'Switch to the inner iframe
Call Driver.SwitchToFrame("dl01")

'Switch to the inner iframe
Call Driver.SwitchToFrame("dl02")

'Get the object of the "download" button
Set oS = Driver.FindElement(By.ID, "dwcb")
'Click the button
oS.Click

'Get the message of the confirmation dialog
strMsg = Driver.GetAlertText()
'Click the OK button of the dialog
Driver.AlertOK

'Wait for the download
'[Important] Wait for a few seconds here, it always happens
Sleep 5000

'Set the popup window as the target (this command will cause it)
Call Driver.SwitchToWindow(strW02)


That's all.

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

2 participants