新手区 [已解决] selenium+phantomjs+python 测试时的问题

adonisjph · 2016年04月14日 · 最后由 wsf 回复于 2016年04月15日 · 1240 次阅读

采用 phantomjs 作为 webdriver 驱动,进行自动化测试
python2.7 作为脚本语言
在使用 driver.quit() 时报错,错误为 [WinError 32] 另一个程序正在使用此文件,进程无法访问。: 'C:\Users\yinshi\AppData\Local\Temp\tmpspgcmvny

后来百度后,发现需要修改 phantomjs 下 service.py 文件中的源码。参照此链接进行修改enter link description here

修改后产生 nameerror:global name permissionerror is not defined,再次百度,在 stackflow 上找到这个enter link description here
大意是说 python 2.7 没有内置的 PermissionError 这个错误类型,python 3.3 有,那么我如果需要手动添加这个错误类型,该如何操作呢

后来实在没办法,想了下是不是 selenium 版本问题,看了下本地的 selenium 是 2.53.1,pypi 上最新的是 2.53.2,更新,搞定。

共收到 1 条回复 时间 点赞

你不捕获这个异常在试试,程序能通过表示就没什么问题。或者捕获 IOError。

需要 登录 後方可回應,如果你還沒有帳號按這裡 注册