I have been experimenting with different methods to open a link in a newly opened tab, but so far none of them have been successful.
Below is a minimal and reproducible example with explanations of what happens after each line (this example uses Selenium webdriver in Java):
driver.get("https://twitter.com") //opens twitter in tab 1 (as intended)
((JavascriptExecutor)driver).executeScript("window.open('https://google.com')"); //opens a new tab (tab 2) and then navigates to google.com (as intended)
((JavascriptExecutor)driver).executeScript("window.location.replace('https://facebook.com')"); //unexpectedly opens facebook.com in tab 1
My goal is to have Facebook open in tab 2 instead.