I have tried to open new tab in existing browser but it opens in new browser.
-
1Add more description and steps to what you are trying to do. Asking 1 line question does not help. also read how to ask a good question on this forum click here and help section click here– AlokCommented Apr 5, 2019 at 7:58
-
How does your code look like? Could you make a simple example how you try to open the new tab. Do understand that a new tab is just a new window, but grouped in a tab. Are you sure it is a new browser and not just a new window?– Niels van ReijmersdalCommented Apr 5, 2019 at 8:28
Add a comment
|
1 Answer
Since you didn't really specify how you're using Selenium this is a general answer.
First of all, make sure it's absolutely necessary to open a new tab. It seems a bit strange as you rarely need to do that.
One way to do it though is to send the keys directly to the browser.
The following should work in C#:
IWebElement body = driver.FindElement(By.TagName("body"));
body.SendKeys(Keys.Control + 't');