selenium3+Python+firefox53 兼容问题

selenium3+Python+firefox53 兼容问题,搞了一天,最后发现是被自己坑了。。。。

电脑安装了,Python2.7 跟Python3   

pytho2.7下面是selenium2.4.x

Python3下面是selenium3.x

 

firefox是53

jdk是1.8

因为电脑jdk环境已经是1.8了,selenium3兼容1.8的,selenium2不兼容1.8的,所有我就用selenium3进行脚本编写

根据selenium3启动firefox高级版本的要求,下载了geckodriver.exe插件,并添加到了环境变量path中

编写脚本如下:

#!/usr/bin/env python
# -*- coding:utf-8 -*-
from selenium import webdriver

driver = webdriver.Firefox()
driver.get("http://www.baidu.com")

结果脚本运行错误:

Traceback (most recent call last):
File "G:/pythoncoding/testing/one.py", line 5, in <module>
driver = webdriver.Firefox()
File "D:\biancheng\Python\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 77, in __init__
self.binary, timeout),
File "D:\biancheng\Python\lib\site-packages\selenium\webdriver\firefox\extension_connection.py", line 49, in __init__
self.binary.launch_browser(self.profile)
File "D:\biancheng\Python\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 68, in launch_browser
self._wait_until_connectable()
File "D:\biancheng\Python\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 103, in _wait_until_connectable
raise WebDriverException("Can't load the profile. Profile "
selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: %s If you specified a log_file in the FirefoxBinary constructor, check it for details.

 

各种百度,都说升级版本,但我的都是最新版本了,不需要升级,百度不到我想要的,后来我看了pycharm设置,发现,Python版本选了2.7的。。。

Python2.7中selenium是2.4.x,所以运行脚本一直报错

后来把Python版本选到Python3.x ,Python3.x下的selenium是3.0,再次运行脚本,成功。

 

 把自己郁闷了一天的原因竟然是被自己坑了。。。。记录一下,长个教训

 

转载于:https://www.cnblogs.com/yishuiqinglian/p/6808912.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值