selenium3+Python+firefox53 兼容問題,搞了一天,最後發現是被本身坑了。。。。python
電腦安裝了,Python2.7 跟Python3 web
pytho2.7下面是selenium2.4.xspa
Python3下面是selenium3.xfirefox
firefox是53插件
jdk是1.8blog
由於電腦jdk環境已是1.8了,selenium3兼容1.8的,selenium2不兼容1.8的,全部我就用selenium3進行腳本編寫utf-8
根據selenium3啓動firefox高級版本的要求,下載了geckodriver.exe插件,並添加到了環境變量path中ci
編寫腳本以下:get
#!/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
各類百度,都說升級版本,但個人都是最新版本了,不須要升級,百度不到我想要的,後來我看了pycharm設置,發現,Python版本選了2.7的。。。
Python2.7中selenium是2.4.x,因此運行腳本一直報錯
後來把Python版本選到Python3.x ,Python3.x下的selenium是3.0,再次運行腳本,成功。
把本身鬱悶了一天的緣由居然是被本身坑了。。。。記錄一下,長個教訓