private static bool switchPage(IWebDriver driver, IWebPage page) { if (page.FromPage() == null) { return(true); } if (driver.WindowHandles.Count == 1) { return(true); } foreach (var window in driver.WindowHandles) { driver.SwitchTo().Window(window); if (page.IsNavigate()) { return(true); } } return(false); }