1.screenshot全屏截图
# coding=utf-8
from selenium import webdriver
import time
from config import setting
driver = 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()