How to switch tabs in a test in C#- MStest?

How to switch tabs in a test in C#- MStest?

Hi Ana Sousa,

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 is passed as a parameter.

The method CurrentWindowHandle yields the window handle ID of the tab that 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]);