We have a legacy remote system here that dont have webapi, webservice, ...
then we need to do integration by Selenium.
We need open multiple tabs from one master tab to
WebDriver will not automatically switch focus to a new window or tab, so we have to tell it when to make the switch.
To switch to the new window/tab, try:
driver.SwitchTo().Window(driver.WindowHandles.Last());
Then, when you are finished on the new tab, close it and switch back to the primary window:
driver.Close();
driver.SwitchTo().Window(driver.WindowHandles.First());
Then from here, you can continue your test.
I'll add a quick disclaimer that I do not have Visual Studio installed on the machine I'm using at the moment and haven't tested the code above. This should, however get you in the right direction.
EDIT: Looking at your code a second time, this example above would replace the SendKeys()
call to attempt to switch tab focus:
IWebElement elmBdy = driver.FindElement(By.CssSelector("body"));
elmBdy.SendKeys(Keys.Control + "2");