簡體   English   中英

在python中,selenium模塊。 如何使用firefox驅動程序

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

我想使用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'

我遇到了同樣的錯誤,但在我安裝firefox時得到修復。 沒意識到沒有安裝firefox。 看看這個。

selenium webdriver為您提供對Web內容的編程訪問。 它驅動一個真正的瀏覽器,所以是的,你需要安裝Firefox來實例化webdriver.Firefox()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM