Is there a way to physically close a tab via Protractor or WebDriver?
I ask because while I know how to switch tabs programmatically, but it does not bring the acti
Close all tabs except first one and switch to first tab:
var tabs = driver.WindowHandles; //
foreach (var tab in tabs)
{
// "tab" is a string like "CDwindow-6E793DA3E15E2AB5D6AE36A05344C68"
if (tabs[0] != tab)
{
driver.SwitchTo().Window(tab);
driver.Close();
}
}
driver.SwitchTab(tabs[0]); // Switch to first tab
driver.SwitchTo().DefaultContent(); // Switch to default frame
Pay attention to last two lines, they are need to avoid such errors like OpenQA.Selenium.NoSuchWindowException: no such window: target window already closed
from unknown error: web view not found