from selenium import webdriver
driver_path = r'D:\python\geckodriver-v0.23.0-win64\geckodriver.exe'
driver = webdriver.Firefox(executable_path=driver_path)
driver.get("https://www.52pojie.cn/")
driver.execute_script("window.open('https://www.xd0.com/')") # 打开多个窗口
print(driver.window_handles) # 打印当前所有窗口
driver.switch_to_window(driver.window_handles[0]) # 切换到第一个窗口
print(driver.current_url)
# print(driver.page_source)
网友评论