常用api操作,错误截图

import os,time
from selenium import webdriver
import datetime
current_path=os.path.dirname(__file__)
wbdr01_path=os.path.join(current_path,'../webdriver/chromedriver.exe')
driver=webdriver.Chrome()
driver.get('https://www.baidu.com')
driver.maximize_window()
driver.find_element_by_name('wd'). send_keys('软件测试')
driver.find_element_by_id('su'). click()
time.sleep(3)
driver.refresh()
time.sleep(3)
driver.back()
time.sleep(3)
driver.forward()
time.sleep(3)
current_data=datetime.datetime.now()
print(current_data)
err_img_path=os.path.join(current_path,'../error_img/03.png')
print(err_img_path)
driver.get_screenshot_as_file(err_img_path)
time.sleep(3)
driver.close()
driver.quit()
原文地址:https://www.cnblogs.com/tingting-yang/p/13335877.html