0

I am developing a program that opens a web driver. Now I want to open that driver and after opening it should open a new chrome tab with a link. How can I do that? Please help

            chrome_options = webdriver.ChromeOptions()
            driver = webdriver.Chrome(ChromeDriverManager().install(), chrome_options=chrome_options)
            driver.get(url)

I am using this to open the driver (url= is a variable from above) after opening want that it opens a new chrome tab please do that!

  • Does this answer your question? [Open web in new tab Selenium + Python](https://stackoverflow.com/questions/28431765/open-web-in-new-tab-selenium-python) – RobinFrcd Sep 27 '20 at 09:10

1 Answers1

0

One way to do that is the following:

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

BASE_URL = "https://www.google.com/" # your url

driver = webdriver.Chrome(
        executable_path=ChromeDriverManager().install()
    )
driver.get(BASE_URL)
driver.execute_script("window.open('');")
driver.switch_to.window(driver.window_handles[1])
driver.get(BASE_URL)

You spawn a new window, switch to the window and perform a new get.