WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60)); wait.Until(driver => { return driver.WindowHandles.Count== waitforHandlesCount; }); string current_handler = driver.CurrentWindowHandle; var all_handler = driver.WindowHandles; driver.SwitchTo().Window(all_handler[all_handler.Count-1]);
通过driver.WindowHandles获取现有所有弹窗页面内集合,最后一个是新加入driver的弹窗页面。可以通过显示等待方式等待弹窗加载标签:WindowHandles,Selenium,driver,新页面,handler,弹窗 From: https://www.cnblogs.com/l1pe1/p/17291589.html