【Selenium】【BugList9】windows环境,fp = open("./"+ time.strftime("%Y-%m-%d %H:%M:%S") + " result.html",'wb'),报错:OSError: [Errno 22] Invalid argument: './2018-09-05 10:29:32 result.html'
【代码】
if __name__=="__main__":
suite = unittest.TestSuite()
suite.addTest(Baidu("test_baidu")) url ="./"+ time.strftime("%Y-%m-%d %H:%M:%S") + " result.html"
fp = open(url,'wb')
runner = HTMLTestRunner(stream = fp,
title = 'Report of Baidu_search',
description = 'TestCase run') runner.run(suite)
fp.close()
【报错】
==================== RESTART: C:/Users/admin/Desktop/1.py ====================
Traceback (most recent call last):
File "C:/Users/admin/Desktop/1.py", line 31, in <module>
fp = open("./"+ time.strftime("%Y-%m-%d %H:%M:%S") + " result.html",'wb')
OSError: [Errno 22] Invalid argument: './2018-09-05 10:29:32 result.html'
【解决思路】
1.python IDLE中:open("./result.html",'wb'),成功
2.去掉“%Y-%m-%d %H:%M:%S”中空格,仍报错
3.修改“%Y-%m-%d %H:%M:%S”中‘:’ 为 ‘-’,成功—>冒号 ‘:’ 引起
4.在python IDLE中,执行 time.strftime("%Y-%m-%d %H:%M:%S") 可成功,但open方法执行却不行?
5.在Windows下,创建文件名带冒号的文件,再用open方法打开,结果:

6.结论:Windows环境,不能创建文件名带英文冒号:的文件,所以open方法创建/打开文件失败
【代码-修改后】
if __name__=="__main__":
suite = unittest.TestSuite()
suite.addTest(Baidu("test_baidu")) url ="./"+ time.strftime("%Y-%m-%d %H_%M_%S") + " result.html"
fp = open(url,'wb')
runner = HTMLTestRunner(stream = fp,
title = 'Report of Baidu_search',
description = 'TestCase run') runner.run(suite)
fp.close()
【Selenium】【BugList9】windows环境,fp = open("./"+ time.strftime("%Y-%m-%d %H:%M:%S") + " result.html",'wb'),报错:OSError: [Errno 22] Invalid argument: './2018-09-05 10:29:32 result.html'的更多相关文章
- 【Selenium + Python】路径报错之OSError: [Errno 22] Invalid argument: './t/report/2018-03-23_11:03:12_report.html'
现象: 此问题真的是太痛苦了,查了好多资料是说路径的问题,结果还是报错,后来一点点的排查才发现原来是!!!!!! 废话不多说上原来代码: if __name__ == '__main__': star ...
- 为什么基于Windows Server 2008 R2的网络负载均衡(NLB)配置的时候总会报错“主机不可访问”?
配置基于Windows的网络负载均衡是很容易的,操作也很简单,点点鼠标基本上就能完成,但是在进行节点(真实服务器)操作的过程中有时候会遇到一些主机不可访问的报错信息.这个又是为什么呢? Figure ...
- python+selenium遇到元素定位不到的问题,顺便记录一下自己这次的错误(报错selenium.common.exceptions.NoSuchElementException)
今天在写selenium一个发送邮件脚本时,遇到一些没有找到页面元素的错误.经过自己反复调试,找原因百度,终于解决了.简单总结一下吧,原因有以下几点: 一:Frame控件嵌套,.Frame/Ifram ...
- Web自动化测试—— Selenium+Python Windows环境搭建
环境搭建前的准备: 1.到Python官网下载Python安装包:https://www.python.org/ 如果不能访问,可以试试下面的解决办法: a).安装VPN网络连接工具,推荐用Green ...
- selenium +python+windows 环境搭建
很久不弄selenium了,好怀念,现在搭建下环境 1,先安装pip ,因为装的是python3,所以只要你不是在渣渣网站下载到坏的版本,在scripts目录下都有pip.exe文件 直接在环境变量里 ...
- Python 3.6版本中实现 HTMLTestRunner输出时”fp=file(filename,'wb')“报错
原错误代码: if __name__=='__main__': suite=unittest.makeSuite(WidgetTestCase) filename='D:\\myreport.html ...
- python3 使用selenium +webdriver打开chrome失败,报错:FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver': 'chromedriver'
提示chrome driver没有放置在正确的路径下 解决方法: 1.chromedriver与chrome各版本及下载地址 驱动的下载地址如下: http://chromedriver.storag ...
- Windows下安装模块mysqlclient报错处理
Windows环境下使用pip命令安装Python模块mysqlclientpip install mysqlclient安装过程报错 [error] Microsoft Visual C++ 14 ...
- 『心善渊』Selenium3.0基础 — 2、Selenium测试框架环境搭建(Windows)
目录 1.浏览器安装 2.浏览器驱动下载 (1)ChromeDriver for Chrome (2)Geckodriver for Firefox (3)IEDriverServer for IE ...
随机推荐
- leetcode894
class Solution { private Map<Integer, List<TreeNode>> memo; public List<TreeNode> ...
- Python OS模块,和Open函数
https://www.cnblogs.com/ginvip/p/6439679.html
- Longest Palindrome 最长回文串问题
1.题目 Given a string s, find the longest palindromic substring in s. You may assume that the maximum ...
- python学习Day14 带参装饰器、可迭代对象、迭代器对象、for 迭代器工作原理、枚举对象、生成器
复习 函数的嵌套定义:在函数内部定义另一个函数 闭包:被嵌套的函数 -- 1.外层通过形参给内层函数传参 -- 2.返回内部函数对象----> 延迟执行, 开放封闭原则: 功能可以拓展,但源代 ...
- 微信小程序创建一个新项目
1. 新建一个文件夹. 2. 打开微信小程序开发工具,导入新建文件夹:然后输入创建的appId:会自动生成一个project.config.json,打开这个文件,会看到appid这个字段. 3.可以 ...
- JS高级总结
网址:https://www.cnblogs.com/signheart/p/d6c229a5a758ee1dc21ad5ca2042ab8f.html 通常,通过 JavaScript,您需要操作 ...
- 云笔记项目-Spring事务学习-传播Requried
在准备好前期的项目搭建后,接下来就一个个的测试,首先测试事务传播的Required Service层两个实现类 Service层两个实现类,只是更换了方法事务传播的属性,其他都一样,后续测试也只修改传 ...
- 将对象序列化成XML字符串
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- Trie树详解(转)
特别声明 本文只是一篇笔记类的文章,所以不存在什么抄袭之类的. 以下为我研究时参考过的链接(有很多,这里我只列出我记得的): Trie(字典树)的应用——查找联系人 trie树 Trie树:应用于统计 ...
- vue根据路由变换,切换导航栏样式
<ul> <li> <router-link :to="{name: 'home'}" class="active_item" e ...