我收到错误消息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