I have been trying many functions to open a link in a tab I recently opened but it does not work.
Minimum reproducible example with commentary saying what happens after each line (this is using Selenium webdriver, Java):
driver.get("https://twitter.com") //opens twitter in tab 1(intended)
((JavascriptExecutor)driver).executeScript("window.open('https://google.com')"); //opens new tab (tab 2) then opens google.com(intended)
((JavascriptExecutor)driver).executeScript("window.location.replace('https://facebook.com')"); //opens facebook.com in tab 1 (unintended)
I want Facebook to open in tab 2 instead.