Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python中,selenium模块。如何使用firefox驱动程序_Python_Firefox_Selenium_Selenium Webdriver - Fatal编程技术网

在python中,selenium模块。如何使用firefox驱动程序

在python中,selenium模块。如何使用firefox驱动程序,python,firefox,selenium,selenium-webdriver,Python,Firefox,Selenium,Selenium Webdriver,我想使用Selenium的Firefox驱动程序。 但是我得到了如下所示的错误。可能是Firefox没有正确安装吗 ------我的消息来源------ ------我的源端------ 以下是返回的错误: Traceback (most recent call last): File "test.py", line 4, in <module> browser = webdriver.Firefox() File "/usr/local/lib/python2.7/

我想使用Selenium的Firefox驱动程序。 但是我得到了如下所示的错误。可能是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'
回溯(最近一次呼叫最后一次):
文件“test.py”,第4行,在
browser=webdriver.Firefox()
文件“/usr/local/lib/python2.7/site packages/selenium-2.25.0-py2.7.egg/selenium/webdriver/firefox/webdriver.py”,第51行,在__
self.binary,超时),
文件“/usr/local/lib/python2.7/site packages/selenium-2.25.0-py2.7.egg/selenium/webdriver/firefox/extension_connection.py”,第47行,在u init中__
self.binary.launch_浏览器(self.profile)
文件“/usr/local/lib/python2.7/site packages/selenium-2.25.0-py2.7.egg/selenium/webdriver/firefox/firefox\u binary.py”,第43行,在launch\u浏览器中
self.\u从配置文件路径开始(self.profile.path)
文件“/usr/local/lib/python2.7/site-packages/selenium-2.25.0-py2.7.egg/selenium/webdriver/firefox/firefox\u binary.py”,第65行,在\u start\u from\u profile\u路径中
env=self.\u firefox\u env.communicate()
文件“/usr/local/lib/python2.7/subprocess.py”,第679行,在__
错误读取,错误写入)
文件“/usr/local/lib/python2.7/subprocess.py”,第1228行,在执行子进程中
引发子对象异常
AttributeError:“非类型”对象没有属性“rfind”

我遇到了同样的错误,但在安装firefox时得到了修复。没有意识到firefox没有安装。请查看。

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

你能在webdriver之外正常启动Firefox吗?chrome或IE驱动程序会发生这种情况吗?
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'