5

我想使用 Selenium 的 Firefox 驱动程序。但我得到了如下所示的错误。火狐可能没有正确安装吗?

------ 我的来源 ------

from selenium import webdriver

driver = webdriver.Firefox()

------ 我的源码完------

这是返回的错误:

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    browser = webdriver.Firefox()
  File "/usr/local/lib/python2.7/site-packages/selenium-2.25.0-py2.7.egg/selenium/webdriver/firefox/webdriver.py", line 51, in __init__
    self.binary, timeout),
  File "/usr/local/lib/python2.7/site-packages/selenium-2.25.0-py2.7.egg/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
    self.binary.launch_browser(self.profile)
  File "/usr/local/lib/python2.7/site-packages/selenium-2.25.0-py2.7.egg/selenium/webdriver/firefox/firefox_binary.py", line 43, in launch_browser
    self._start_from_profile_path(self.profile.path)
  File "/usr/local/lib/python2.7/site-packages/selenium-2.25.0-py2.7.egg/selenium/webdriver/firefox/firefox_binary.py", line 65, in _start_from_profile_path
    env=self._firefox_env).communicate()
  File "/usr/local/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/usr/local/lib/python2.7/subprocess.py", line 1228, in _execute_child
    raise child_exception
AttributeError: 'NoneType' object has no attribute 'rfind'
4

2 回答 2

4

I faced the same error but got fixed when I installed firefox. Didn't realise that firefox was not installed. Check it out.

于 2012-10-29T05:30:34.387 回答
0

selenium webdriver 为您提供对 Web 内容的编程访问。它驱动一个真正的浏览器,所以是的,你需要安装 Firefox 来实例化webdriver.Firefox().

于 2013-08-12T13:23:47.840 回答