无法使用selenium,python加载firefox配置文件

时间:2016-03-10 10:26:15

标签: python selenium firefox centos pip

我有2台机器Centos 6.7,与pip,python,firefox和selenium版本完全相同。
Python 2.6.6,
点7.1.0,
硒== 2.52.0,
Mozilla Firefox 38.6.1,
PyVirtualDisplay == 0.2,

我的代码是

#!/usr/bin/env python

from pyvirtualdisplay import Display
from selenium import webdriver


display = Display(visible=0, size=(1024, 768))
display.start()

browser = webdriver.Firefox()
browser.get('http://www.ubuntu.com/')
print browser.page_source

browser.close()
display.stop()

在一台机器上完美运行,在另一台机器上它给我这个错误

        browser = webdriver.Firefox (firefox_binary = webdriver.firefox.firefox_binary.FirefoxBinary (log_file = open ('/tmp/selenium.log', 'a')))
  File "/usr/lib/python2.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 78, in __init__
    self.binary, timeout)
  File "/usr/lib/python2.6/site-packages/selenium/webdriver/firefox/extension_connection.py", line 51, in __init__
    self.binary.launch_browser(self.profile, timeout=timeout)
  File "/usr/lib/python2.6/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 68, in launch_browser
    self._wait_until_connectable(timeout=timeout)
  File "/usr/lib/python2.6/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 106, in _wait_until_connectable
    % (self.profile.path))
selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: /tmp/tmpDZ6INh If you specified a log_file in the FirefoxBinary constructor, check it for details.
你对这个问题有什么看法吗?

谢谢。

1 个答案:

答案 0 :(得分:0)

我发现127.0.0.1在机器防火墙中被阻止!!!!真奇怪 !!这就是问题