public void DoNotCloseTwoNewWindows() { string parentWindow = _driver.CurrentWindowHandle; MultipleWindoButton.Click(); //_driver.Close(); }
public void OpenMultipleWindows() { string parentWindow = _driver.CurrentWindowHandle; MultipleWindoButton.Click(); //Get all the open window handles List <string> windowHandles = _driver.WindowHandles.ToList(); //Iterate through handles and if its not parentWindow close it foreach (var window in windowHandles) { if (!window.Equals(parentWindow)) { _driver.SwitchTo().Window(window); _driver.Close(); } } //return to parent window _driver.SwitchTo().Window(parentWindow); }