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:Python33selenium8.py", line 3, in
driver = webdriver.Firefox()
File "C:Python33libsite-packagesselenium-2.45.0-py3.3.eggseleniumwebdriverfirefoxwebdriver.py", line 59, in init
self.binary, timeout),
File "C:Python33libsite-packagesselenium-2.45.0-py3.3.eggseleniumwebdriverfirefoxextension_connection.py", line 47, in init
self.binary.launch_browser(self.profile)
File "C:Python33libsite-packagesselenium-2.45.0-py3.3.eggseleniumwebdriverfirefoxfirefox_binary.py", line 66, in launch_browser
self._wait_until_connectable()
File "C:Python33libsite-packagesselenium-2.45.0-py3.3.eggseleniumwebdriverfirefoxfirefox_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了,嘿嘿。又前进了一步!!