python selenium 不支持 firefox - 消息 : Can't load the profile. Profile Dir

标签 python selenium firefox

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

火狐浏览器 45.0 selenium.版本 '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.

最佳答案

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

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

sudo pip install -U selenium 

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

关于python selenium 不支持 firefox - 消息 : Can't load the profile. Profile Dir,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37380746/

相关文章:

python - python中关于邻接矩阵的Dijkstra算法

python - 调用类成员函数给出 TypeError

python - Pandas Dataframe 列到 python 列表

selenium - Selenium XPath text()-简单选择似乎不起作用

firefox - Firefox 是否有清除缓存的键盘快捷键?

python - 使用粗略的灰度算法有问题吗?

python - 使用 Selenium Actionchains 时指定 Actions 之间的等待时间

angular - 元素状态无效 : Element must be user-editable in order to clear it error trying to click and insert a date on a dropdown-toggle using Selenium

html - 为什么我的 html canvas 游戏不能在 firefox 上运行?

css - Firefox 中的随机空间问题