首页 > 其他 > 详细

场景:生成截图的时候失败

时间:2017-11-18 20:47:13      阅读:216      评论:0      收藏:0      [点我收藏+]

生成截图用的

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)

 

场景:生成截图的时候失败

原文:http://www.cnblogs.com/wang-shh/p/7857680.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!