1234567891011121314151617181920212223from selenium import webdriver driver = webdriver.Chrome() # 设置页面加载时间driver.set_page_load_timeout(5) start = time.time() try: driver.get(driver.get('https://www.baidu.com'))except: # 捕获timeout异常 driver.execute_script('window.stop()') # 执行Javascript来停止页面加载 window.stop() end = time.time()# 页面加载所需时间print(end-start) el = driver.find_element("name", value='wd')#对元素输入文本el.send_keys('这是我的第一次尝试')#找到搜索按钮并点击一次driver.find_element("id", value='su').click()