IOError: [Errno 2] No such file or directory: ‘selenium\\webdriver\\remote\\getAttribute.js‘

环境:python2.7 13 +selenium (3.4.3)

报错如下:
Traceback (most recent call last):
  File "TestStart.py", line 17, in <module>
  File "DataDrawout.pyo", line 10, in <module>
  File "PackFunction.pyo", line 3, in <module>
  File "selenium\webdriver\__init__.pyo", line 18, in <module>
  File "selenium\webdriver\firefox\webdriver.pyo", line 34, in <module>
  File "selenium\webdriver\remote\webdriver.pyo", line 25, in <module>
  File "selenium\webdriver\remote\webelement.pyo", line 40, in <module>
  File "pkgutil.pyo", line 591, in get_data
IOError: [Errno 2] No such file or directory: 'selenium\\webdriver\\remote\\getAttribute.js'


解决方法:
C:\Python27\Lib\site-packages\selenium\webdriver\remote\webelement.py中
getAttribute_js = pkgutil.get_data(__package__, 'getAttribute.js').decode('utf8')
isDisplayed_js = pkgutil.get_data(__package__, 'isDisplayed.js').decode('utf8')

修改为:
import sys

frozen = getattr(sys, 'frozen', '')
if not frozen:
    getAttribute_js = pkgutil.get_data(__package__, 'getAttribute.js').decode('utf8')
    isDisplayed_js = pkgutil.get_data(__package__, 'isDisplayed.js').decode('utf8')
else:
    approot = os.path.dirname(sys.executable)
    getAttribute_js = open(os.path.join(approot, 'getAttribute.js'), 'rb').read().decode('utf8')
    isDisplayed_js = open(os.path.join(approot, 'isDisplayed.js'), 'rb').read().decode('utf8')
 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值