How to switch tabs in a test with SpecFlow?

How to switch tabs in a test with SpecFlow?

Hello Brettm,

By default, the WebDriver can access only the parent tab. To access the second tab, we have to switch the driver focus with the help of the SwitchTo().Window() method. The window handle id of the tab where we want to switch to passed as a parameter.

The method CurrentWindowHandle yields the window handle id of the tab which is in focus. The WindowHandles method returns all the window handle id of the opened tabs in the browser.

Use the below snippet:

driver.SwitchTo().Window(driver.WindowHandles[1]);