在Mac上,使用virtualenv和python来尝试Selenium。我从http://selenium-python.readthedocs.org/getting-started.html上的简单用法部分逐字复制并粘贴了示例代码 并运行它。 Firefox启动,但没有任何反应。片刻之后什么都不做,Firefox关闭,我得到了粘贴在
下面的错误最初我认为问题是版本差异。我在FF v28和Selenium 2.41
有什么想法吗?
(venv)1:tests danny$ python acceptance.py
Traceback (most recent call last):
File "acceptance.py", line 4, in <module>
driver = webdriver.Firefox()
File "/Users/danny/Sites/school/asa/venv/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 59, in __init__
self.binary, timeout),
File "/Users/danny/Sites/school/asa/venv/lib/python2.7/site-packages/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
self.binary.launch_browser(self.profile)
File "/Users/danny/Sites/school/asa/venv/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 61, in launch_browser
self._wait_until_connectable()
File "/Users/danny/Sites/school/asa/venv/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 105, in _wait_until_connectable
self.profile.path, self._get_firefox_output()))
selenium.common.exceptions.WebDriverException: Message: "Can't load the profile. Profile Dir: /var/folders/sm/tx8hy4bx1cgg176rthqylwh00000gn/T/tmpvhQdUO Firefox output: *** LOG addons.xpi: startup\n*** LOG addons.xpi: Skipping unavailable install location app-system-share\n*** LOG addons.xpi: checkForChanges\n*** LOG addons.xpi: No changes found\n*** Blocklist::_loadBlocklistFromFile: blocklist is disabled\nJavaScript error: chrome://browser/content/urlbarBindings.xml, line 648: aUrl is undefined\n"
答案 0 :(得分:0)
我收到同样的错误,在调整本地防火墙规则后它开始工作了。我没有时间检查所需端口的定义位置,它似乎是随机选择的,所以暂时我允许本地所有TCP端口(127.0.0.1 - > 127.0.0.1),之后它工作正常。我实际上使用了readthedocs.org中的相同代码。