Selenium_获取界面handle、title和url(7)
from selenium import webdriver driver = webdriver.Chrome() driver.maximize_window() driver.get("https://www.baidu.com") # 获取当前界面的handle(handle用于窗口切换) page_handle = driver.current_window_handle print(page_handle) # 获取所有窗口的handle handles = driver.window_handles print(handles) # 获取界面title信息 page_title = driver.title print(page_title) # 获取界面URL page_url = driver.current_url print(page_url) driver.close()