selenium8.py
coding = utf-8
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('http://www.baidu.com')
print (driver.title)
driver.quit()
運行報錯:
Python 3.3.5 (v3.3.5:62cf4e77f785, Mar 9 2014, 10:37:12) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
================================ RESTART ================================
Traceback (most recent call last):
File "C:\Python33\selenium8.py", line 3, in
driver = webdriver.Firefox()
File "C:\Python33\lib\site-packages\selenium-2.45.0-py3.3.egg\selenium\webdriver\firefox\webdriver.py", line 59, in
init
self.binary, timeout),
File "C:\Python33\lib\site-packages\selenium-2.45.0-py3.3.egg\selenium\webdriver\firefox\extension_connection.py", line 47, in
init
self.binary.launch_browser(self.profile)
File "C:\Python33\lib\site-packages\selenium-2.45.0-py3.3.egg\selenium\webdriver\firefox\firefox_binary.py", line 66, in launch_browser
self._wait_until_connectable()
File "C:\Python33\lib\site-packages\selenium-2.45.0-py3.3.egg\selenium\webdriver\firefox\firefox_binary.py", line 105, 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.
估計很多朋友都遇到過啊,網上搜了下是版本問題。
我的selenium版本是selenium-2.45.0,安裝的fireFox最新的47版本,結果就報錯了。
fireFox更新的快,但是selenium總是慢半拍。
反正現在是學習嘛,換FireFox版本吧
也不知道selenium-2.45.0,到底支持哪個版本的FireFox,百度搜索到一篇之前的文章說selenium-2.45.0,新發布了,支持FireFox36
一下子降低了11個版本號,好吧,反正是學習。
卸載新的FireFox,安裝了36的版本。
接着運行:
================================ RESTART ================================
百度一下,你就知道
看來是通過了。
那么接下來就是學習selenium了,嘿嘿。又前進了一步!!