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!
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.