标签:技术 join name drive driver 截图功能 play alt eve
没什么可说的,设定好存放截图的路径就行。。
from selenium import webdriver import os import time def create_img(driver, imgname): base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ‘‘‘存放截图路经‘‘‘ phone_path = os.path.join( base_dir + ‘\\TestReport\\screenshot\\‘ + imgname) driver.get_screenshot_as_file(phone_path) if __name__ == "__main__": driver = webdriver.Chrome() driver.get("http://www.baidu.com") time.sleep(0.2) create_img(driver, ‘baidu.png‘) driver.quit()
标签:技术 join name drive driver 截图功能 play alt eve
原文地址:https://www.cnblogs.com/97xiaolai/p/11738443.html