UI自动化生成截图
生成截图用的currentTimeToS = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time()))
currentTimeToD = time.strftime("%Y-%m-%d", time.localtime(time.time())
path = 'C:\\Git\\Intelligent correction' + '\\' + currentTimeToD + '\\' + currentTimeToS + '.jpg'
driver.get_screenshot_as_file('C:\\Git'+'\\'+currentTimeToD+'\\'+currentTimeToS+'.jpg')
由于“currentTimeToD”这个文件夹不存在,所以不能创建成功
解决方法:
makedirs()方法来递归创建目录
currentTimeToS = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time()))
currentTimeToD = time.strftime("%Y-%m-%d", time.localtime(time.time()))
path = 'C:\\Git\\Intelligent correction' + '\\' + currentTimeToD + '\\' + currentTimeToS + '.jpg'
os.makedirs(path)
driver.get_screenshot_as_file('C:\\Git'+'\\'+currentTimeToD+'\\'+currentTimeToS+'.jpg') 支持分享
页:
[1]