When I click on a link in my test, it opens a new tab. I want ChromeDriver to then focus on that tab. I have tried the following code to get ChromeDriver to change tabas using
After a long fight with this I was able to get this working with chrome driver. The alert message is not visible but brings tab to front and accept closes it immediately.
//Rotate Tabs
seleniumDriver.SwitchTo().Window(seleniumDriver.WindowHandles[currentUrlIndex]);
IJavaScriptExecutor jscript = seleniumDriver as IJavaScriptExecutor;
jscript.ExecuteScript("alert('Focus')");
seleniumDriver.SwitchTo().Alert().Accept();