1.screenshot全屏截图
# coding=utf-8from selenium import webdriverimport timefrom config import settingdriver = webdriver.Chrome(r'C:\Users\86185\Desktop\DemoUI\driver\chromedriver.exe')driver.get("https://www.baidu.com")driver.maximize_window()time.sleep(2)picture_time = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time()))print(picture_time)try: picturePath=driver.get_screenshot_as_file(setting.TEST_REPORT+'\\screenshot\\'+ picture_time +'.png') print("%s:截图成功!!!" % picturePath) #图片地址——绝对路径except BaseException as msg: print(msg)driver.quit()