0

I know how to open a new window using selenium. But I want a new tab in the same window of chrome which I am using. How to do that.

KUSHAGRA BANSAL
  • 85
  • 1
  • 10
  • Does this answer your question? [How to open a new tab using Selenium WebDriver?](https://stackoverflow.com/questions/17547473/how-to-open-a-new-tab-using-selenium-webdriver) – JaSON Aug 11 '20 at 08:29
  • Actually, what I want is that wen we open new sites in browser, we have already been logged in that site and there is no need to login to eery website which we open. But when I use selenium's driver.get(url) it open in a new window where I have to login to that site again. This makes the whole automation process very tedius. So I am looking for its solution. – KUSHAGRA BANSAL Aug 11 '20 at 08:34
  • I'm not sure if I've understood the issue, but it seem that you might need to [save/use cookies](https://stackoverflow.com/questions/15058462/how-to-save-and-load-cookies-using-python-selenium-webdriver) for following web-navigation – JaSON Aug 11 '20 at 08:40

1 Answers1

0

If you want to open particular element in newtab use below code segment

String selectLinkOpeninNewTab = Keys.chord(Keys.CONTROL, Keys.RETURN);
// your element 
        WebElement newtab = driver.findElement(By.xpath("element xpath"));
        newtab.sendKeys(selectLinkOpeninNewTab);
Justin Lambert
  • 940
  • 1
  • 7
  • 13