首页 > 编程语言 > 详细

selenium3+Python+firefox53 兼容问题

时间:2017-05-04 19:18:36      阅读:498      评论:0      收藏:0      [点我收藏+]

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,再次运行脚本,成功。

技术分享

 

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

 

selenium3+Python+firefox53 兼容问题

原文:http://www.cnblogs.com/yishuiqinglian/p/6808912.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!