How to switch tabs in C#- xUnit tests?
Hi Ana Sousa,
By default, the WebDriver can access only the parent tab. To access the second tab, you 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 is 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 IDs of the opened tabs in the browser.
Syntax:
driver.SwitchTo().Window(driver.WindowHandles[1]);