0

我收到一条错误消息,提示No Window found我正在尝试切换到窗口,下面是我正在使用的代码。

        VisitMyWebSite();

        string originalHandle = driver.CurrentWindowHandle;

        IWebElement addtoList = driver.FindElement(By.XPath(_pageName));
        addtoList.Click();

        ReadOnlyCollection<string> windowHandles = driver.WindowHandles;
        string popupHandle = string.Empty;

        foreach (string handle in windowHandles)
        {
            if (handle != originalHandle)
            {
                popupHandle = handle; break;
            }
        }

        Thread.Sleep(4000);

        //switch to new window 
        driver.SwitchTo().Window(popupHandle);  //error No Window found
4

0 回答 0