python selenium不能与firefox一起扩展 - 消息:无法加载配置文件。个人资料目录

时间:2016-05-22 23:39:36

标签: python selenium firefox

为什么使用selenium与python和firefox会发生这种情况?硒不能缩放到简单的循环。为何不能使用firefox规模?随着时间的推移,它决定抛出错误并退出。

Mozilla Firefox 45.0 硒版本 '2.53.2'

from pyvirtualdisplay import Display
display = Display(visible=0, size=(800, 600))
display.start()
mylist = ['page1','page1',...,'pageN']
while True:
   for data in mylist:

        browser = webdriver.Firefox()
        try:
           myfunc(data) # Code that uses selenum to fetch pages
        except:
            pass
        browser.quit()
   time.sleep(60)



No handlers could be found for logger "sentry.errors.serializer"
Traceback (most recent call last):
  File "platrieveerp.py", line 231, in <module>
    browser = webdriver.Firefox()
  File "/usr/local/lib/python2.7/dist-packages/selenium-2.53.2-py2.7.egg/selenium/webdriver/firefox/webdriver.py", line 103, in __init__
    self.binary, timeout)
  File "/usr/local/lib/python2.7/dist-packages/selenium-2.53.2-py2.7.egg/selenium/webdriver/firefox/extension_connection.py", line 51, in __init__
    self.binary.launch_browser(self.profile, timeout=timeout)
  File "/usr/local/lib/python2.7/dist-packages/selenium-2.53.2-py2.7.egg/selenium/webdriver/firefox/firefox_binary.py", line 68, in launch_browser
    self._wait_until_connectable(timeout=timeout)
  File "/usr/local/lib/python2.7/dist-packages/selenium-2.53.2-py2.7.egg/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/tmpOgsKOx If you specified a log_file in the FirefoxBinary constructor, check it for details.

1 个答案:

答案 0 :(得分:1)

运行循环时Selenium没有失败,它在webdriver.Firefox()失败了。当脚本仍然无法识别打开的firefox应用程序时,在231行之后的某个时间连接超时时,会识别错误。

使用无头浏览器运行时,这只是硒中的一个错误。要获得selenium的工作版本,请运行

sudo pip install -U selenium 

这应该是一个类似的问题: Selenium: FirefoxProfile exception Can't load the profile