2014-09-30 32 views
4

我嘗試發射了Firefox和得到以下錯誤:硒的webdriver無法加載配置文件

--------------------------------------------------------------------------- 
WebDriverException      Traceback (most recent call last) 
<ipython-input-10-9e1140c380e1> in <module>() 
----> 1 t = tweepi.Tweepi(username, 0, profile_name) 

/home/ubuntu/twitter/tweepi.pyc in __init__(self, username, threadid, profilename) 
    22    profile = webdriver.FirefoxProfile(profilename) 
    23    self.logger.debug('launching firefox') 
---> 24    self.driver = webdriver.Firefox(firefox_profile = profile) 
    25   else: 
    26    self.driver = webdriver.Firefox() 

/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.pyc in __init__(self, firefox_profile, firefox_binary, timeout, capabilities, proxy) 
    57   RemoteWebDriver.__init__(self, 
    58    command_executor=ExtensionConnection("127.0.0.1", self.profile, 
---> 59    self.binary, timeout), 
    60    desired_capabilities=capabilities, 
    61    keep_alive=True) 

/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/extension_connection.pyc in __init__(self, host, firefox_profile, firefox_binary, timeout) 
    45   self.profile.add_extension() 
    46 
---> 47   self.binary.launch_browser(self.profile) 
    48   _URL = "http://%s:%d/hub" % (HOST, PORT) 
    49   RemoteConnection.__init__(

/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.pyc in launch_browser(self, profile) 
    62 
    63   self._start_from_profile_path(self.profile.path) 
---> 64   self._wait_until_connectable() 
    65 
    66  def kill(self): 

/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.pyc in _wait_until_connectable(self) 
    106     raise WebDriverException("Can't load the profile. Profile " 
    107      "Dir: %s Firefox output: %s" % (
--> 108       self.profile.path, self._get_firefox_output())) 
    109    count += 1 
    110    time.sleep(1) 

WebDriverException: Message: "Can't load the profile. Profile Dir: /tmp/tmp4nBIo5/webdriver-py-profilecopy Firefox output: None" 

現在,所有其他類似的線程我發現這裏的計算器說,解決的辦法是通過更新硒使用命令

pip install -U selenium

這解決了我的本地計算機上的問題,但問題仍然存在於AWS上的遠程計算機上。這兩臺電腦具有相同的Firefox版本,都具有最新的硒,甚至在〜/ .mozilla/firefox上也有完全相同的配置文件夾。

有什麼建議嗎?

編輯:

我可以在沒有配置文件的情況下啓動Firefox。也就是說,做

w = webdriver.Firefox() 

作品,而這樣做

profile_name = '/home/ubuntu/.mozilla/firefox/amozqob6.profile6' 
profile = webdriver.FirefoxProfile(profile_name) 
w = webdriver.Firefox(firefox_profile=profile) 

得到上面的錯誤消息。

EDIT2:

運行Firefox的可執行文件直接作用:

firefox -profile ~/.mozilla/firefox/amozqob6.profile6 
+0

您能夠啓動硒會議沒有自定義配置文件?嘗試在遠程啓動一個vanilla Firefox Webdriver實例。 – 2014-09-30 17:38:03

+0

@SilasRay事實上,它的工作原理。我更新了這個問題。建議? – oneloop 2014-09-30 17:44:08

+0

我對Firefox配置文件的內幕知之甚少,但作爲第一個刺,您是否偶然創建了您在不同的操作系統上使用的配置文件,而不是您的AWS實例?我不知道FF配置文件是否可以跨操作系統移植。 – 2014-09-30 17:46:07

回答

3

幫我指定的二進制文件的顯式路徑火狐

from selenium.webdriver.firefox.firefox_binary import FirefoxBinary 
binary = FirefoxBinary("/home/teddy/firefox/firefox") 
driver = webdriver.Firefox(firefox_binary=binary) 
相關問題