2012-09-24 92 views
5

我想使用Selenium的Firefox驅動程序。 但我得到如下所示的錯誤。 Firefox可能沒有正確安裝嗎?在python中,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' 
+1

你可以在webdriver之外正常啓動Firefox嗎?這是否發生在Chrome或IE驅動程序? – Arran

回答

4

我面臨同樣的錯誤,但在我安裝firefox時得到了修復。沒有意識到,Firefox未安裝。一探究竟。

0

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

相關問題