【发布时间】:2016-09-03 09:11:20
【问题描述】:
我正在尝试使用以下代码在我的 Mac 上使用 Selenium 和 Python 3.5 启动 Firefox (48.0.2):
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://bbc.co.uk')
但是,Firefox 启动时没有转到指定的网页并超时并显示以下错误消息:
Traceback (most recent call last):
File "/Users/anthonyperera/Documents/Python/AutomatePython/seleniumexample.py", line 2, in <module>
browser = webdriver.Firefox()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py", line 80, in __init__
self.binary, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/firefox/extension_connection.py", line 52, in __init__
self.binary.launch_browser(self.profile, timeout=timeout)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 68, in launch_browser
self._wait_until_connectable(timeout=timeout)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 108, in _wait_until_connectable
% (self.profile.path))
selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: /var/folders/6n/_xgjldp12r59c6gdvgb46nsm0000gn/T/tmpwlxtjbt4 If you specified a log_file in the FirefoxBinary constructor, check it for details.
【问题讨论】:
-
你的 selenium 是什么版本的?尝试更新 selenium。
-
嗨 Syed,它是最新版本 - 2.53.6