简体   繁体   English

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

[英]In python, selenium module . how to use firefox driver

I want to use Selenium's Firefox driver. 我想使用Selenium的Firefox驱动程序。 But I got the error shown below. 但是我得到了如下所示的错误。 Is it possible that Firefox didn't install properly? Firefox有可能无法正常安装吗?

------ my source ------ ------我的来源------

from selenium import webdriver

driver = webdriver.Firefox()

------ my source End------ ------我的源头------

Here is the error that was returned: 这是返回的错误:

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'

I faced the same error but got fixed when I installed firefox. 我遇到了同样的错误,但在我安装firefox时得到修复。 Didn't realise that firefox was not installed. 没意识到没有安装firefox。 Check it out. 看看这个。

selenium webdriver gives you programmatic access to web content. selenium webdriver为您提供对Web内容的编程访问。 It drives a real browser, so yes, you need Firefox installed to instantiate webdriver.Firefox() . 它驱动一个真正的浏览器,所以是的,你需要安装Firefox来实例化webdriver.Firefox()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM