我想使用Selenium的Firefox驱动程序。 但是我得到了如下所示的错误。 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'
答案 0 :(得分:4)
我遇到了同样的错误,但在我安装firefox时得到修复。没意识到没有安装firefox。看看吧。
答案 1 :(得分:0)
selenium webdriver为您提供对Web内容的编程访问。它驱动真正的浏览器,所以是的,您需要安装Firefox才能实例化webdriver.Firefox()
。