zoukankan      html  css  js  c++  java
  • 【Selenium + Python】路径报错之OSError: [Errno 22] Invalid argument: './t/report/2018-03-23_11:03:12_report.html'

    现象:

    此问题真的是太痛苦了,查了好多资料是说路径的问题,结果还是报错,后来一点点的排查才发现原来是!!!!!!

    废话不多说上原来代码:

     1 if __name__ == '__main__':
     2     startime = time.strftime('%H:%M:%S')
     3     print("开始时间为:%s" % startime)
     4     #测试路径
     5     test_dir = './t/test_case'
     6     #报告路径
     7     report_dir = './t/report/'
     8 
     9     now = time.strftime('%Y-%m-%d_%H:%M:%S')
    10     # 创建完整报告文件
    11     filename = report_dir + now + '_report.html'
    12     fp = open(filename,'wb')

     看到没有!!看第九行,now的获取时间有问题!!!时分秒之间不能用冒号:,不能用冒号:,不能用冒号:,重要的事情说三遍!!!真的要哭了!!!

    修改如下:

     1 if __name__ == '__main__':
     2     startime = time.strftime('%H:%M:%S')
     3     print("开始时间为:%s" % startime)
     4     #测试路径
     5     test_dir = './t/test_case'
     6     #报告路径
     7     report_dir = './t/report/'
     8 
     9     now = time.strftime('%Y-%m-%d_%H_%M_%S')
    10     # 创建完整报告文件
    11     filename = report_dir + now + '_report.html'
    12     fp = open(filename,'wb')
  • 相关阅读:
    作业1-1 打印华氏温度与摄氏温度对照表
    python配置yaml
    python读写Excel方法(xlwt和xlrd)
    python发送邮件(smtplib)
    python之os模块(os.path)
    python简单面试题(2)
    python---Logging日志模块
    python---python装饰器
    如何从零开始学习自动化
    软件测试不得不知的基础知识
  • 原文地址:https://www.cnblogs.com/Owen-ET/p/8629194.html
Copyright © 2011-2022 走看看