未知错误:会话因未知错误导致页面崩溃而被删除:无法确定 ChromeDriver Selenium 崩溃的选项卡的加载状态

2024-04-25

我正在使用 InstaPy,它使用 Python 和 Selenium。我按照 Cron 启动脚本,但有时它会崩溃。所以它确实很不规则,有时它却贯穿得很好。我已经在 GitHub Repo 上发布了,但没有得到答案,所以我现在在这里询问是否有人知道原因。

这是一个数字海洋 ubuntu 服务器,我在无头模式下使用它。驱动程序版本在日志中可见。以下是错误消息:

ERROR [2018-12-10 09:53:54] [user]  Error occurred while deleting cookies from web browser!
b'Message: invalid session id\n  (Driver info: chromedriver=2.44.609551 (5d576e9a44fe4c5b6a07e568f1ebc753f1214634),platform=Linux 4.15.0-42-generic x86_64)\n'
Traceback (most recent call last):
  File "/root/InstaPy/instapy/util.py", line 1410, in smart_run
    yield
  File "./my_config.py", line 43, in <module>
    session.follow_user_followers(['xxxx','xxxx','xxxx','xxxx'], amount=100, randomize=True, interact=True)
  File "/root/InstaPy/instapy/instapy.py", line 2907, in follow_user_followers
    self.logfolder)
  File "/root/InstaPy/instapy/unfollow_util.py", line 883, in get_given_user_followers
    channel, jumps, logger, logfolder)
  File "/root/InstaPy/instapy/unfollow_util.py", line 722, in get_users_through_dialog
    person_list = dialog_username_extractor(buttons)
  File "/root/InstaPy/instapy/unfollow_util.py", line 747, in dialog_username_extractor
    person_list.append(person.find_element_by_xpath("../../../*")
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webelement.py", line 351, in find_element_by_xpath
    return self.find_element(by=By.XPATH, value=xpath)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webelement.py", line 659, in find_element
    {"using": by, "value": value})['value']
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webelement.py", line 633, in _execute
    return self._parent.execute(command, params)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: session deleted because of page crash
from unknown error: cannot determine loading status
from tab crashed
  (Session info: headless chrome=70.0.3538.110)
  (Driver info: chromedriver=2.44.609551 (5d576e9a44fe4c5b6a07e568f1ebc753f1214634),platform=Linux 4.15.0-42-generic x86_64)

During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
  File "/root/InstaPy/instapy/instapy.py", line 3845, in end
    self.browser.delete_all_cookies()
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 878, in delete_all_cookies
    self.execute(Command.DELETE_ALL_COOKIES)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: chrome not reachable
  (Session info: headless chrome=71.0.3578.80)
  (Driver info: chromedriver=2.44.609551 (5d576e9a44fe4c5b6a07e568f1ebc753f1214634),platform=Linux 4.15.0-42-generic x86_64)

知道原因是什么以及如何解决吗?

感谢您的投入。还有来自的家伙们http://treestones.ch/ http://treestones.ch/帮助我。


尽管您看到错误为:

Error occurred while deleting cookies from web browser!
b'Message: invalid session id\n  (Driver info: chromedriver=2.44.609551 (5d576e9a44fe4c5b6a07e568f1ebc753f1214634),platform=Linux 4.15.0-42-generic x86_64)\n'

主要的例外是:

selenium.common.exceptions.WebDriverException: Message: unknown error: session deleted because of page crash
from unknown error: cannot determine loading status
from tab crashed

您的代码试验会给我们一些出错的线索。


Solution

这个问题有多种解决方案。然而根据未知错误:由于选项卡崩溃导致页面崩溃,会话被删除 https://github.com/elgalu/docker-selenium/issues/20此问题可以通过以下任一解决方案来解决:

  • 添加以下内容chrome_options:

    chrome_options.add_argument('--no-sandbox')         
    
  • 由于太小,Chrome 似乎在某些页面上的 Docker 容器中崩溃/dev/shm。所以你可能需要修复一些小问题/dev/shm size.

  • 一个例子:

    sudo mount -t tmpfs -o rw,nosuid,nodev,noexec,relatime,size=512M tmpfs /dev/shm
    
  • 如果您使用它也有效-v /dev/shm:/dev/shm分享选项host /dev/shm

  • 使其工作的另一种方法是添加chrome_options as --disable-dev-shm-usage。这将强制 Chrome 使用/tmp目录代替。但这可能会减慢执行速度,因为将使用磁盘而不是内存。

    chrome_options.add_argument('--disable-dev-shm-usage')        
    

从选项卡崩溃

从选项卡崩溃是 WIP(工作正在进行中)与铬团队相当长一段时间以来,这涉及到Linux 尝试始终使用 /dev/shm 作为不可执行内存。以下是参考资料:

  • Linux:Chrome/Chromium SIGBUS/哇,啪!在小 /dev/shm 上 https://bugs.chromium.org/p/chromium/issues/detail?id=522853
  • 当 /dev/shm 太小时,Chrome 崩溃/加载失败,并且位置无法覆盖 https://bugs.chromium.org/p/chromium/issues/detail?id=715363
  • As per 评论61#问题736452 https://bugs.chromium.org/p/chromium/issues/detail?id=736452#c61修复似乎已经完成Chrome v65.0.3299.6

参考

您可以在以下位置找到一些相关讨论:

  • org.openqa.selenium.SessionNotCreatedException:从 Jenkins CI 服务器执行时,选项卡崩溃错误导致会话未创建异常 https://stackoverflow.com/questions/49518157/org-openqa-selenium-sessionnotcreatedexception-session-not-created-exception-fr/49518339#49518339
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

未知错误:会话因未知错误导致页面崩溃而被删除:无法确定 ChromeDriver Selenium 崩溃的选项卡的加载状态 的相关文章

  • 生成非连续组合

    我正在尝试创建一个生成器 支持执行 next 的迭代器 可能在 python 中使用yield 它给出来自 1 2 n n 和 r 是参数 的 r 元素的所有组合 这样在选出的r个元素 没有两个是连续的 例如 对于 r 2 且 n 4 生成
  • Google PubSub 在阻止和等待消息时没有标准输出

    我正在使用这个问题底部的 Python 代码监听 Google PubSub 消息 它实际上是来自 Google 的异步拉取示例 我运行我的程序并输出到文件 python my script py tee log txt 如果我在接收消息时
  • tf.keras.utils.image_dataset_from_directory,但标签来自 csv?

    请告诉我哪里出错了 我正在研究 Kaggle 狗品种分类挑战 我想尝试 one hot 编码与标签编码 图像未在图像目录中拆分 因此我无法将 推断 与 tf keras utils image dataset from directory
  • 如何使用 XPath 和 Selenium Webdriver 提取 XML 数据

    我正在使用 Selenium Webdriver ver 2 31 2 0 Net 我正在尝试提取从 driver PageSource 返回的元素 XML 我的问题 如何使用下面的 xpath 获取项目列表 我可以使用 XPATH 插件在
  • 单击按钮时执行 python 脚本

    我有一个带有一个按钮的 HTML 页面 当我们单击该按钮时 我需要执行一个 python 脚本 并返回到包含结果的同一 HTML 页面 所以我需要对返回值进行一些验证并执行一些操作 这是我的代码 HTML
  • Selenium 2:中断页面加载

    我在使用 FirefoxDriver 使用 Selenium 2 0b3 Java API 单击按钮时遇到问题 单击该按钮会将表单发送到网络服务器 然后浏览器会因表单提交而进入新页面 当使用 element click 单击某个元素时 se
  • Chrome 的萤火虫

    谁能推荐一个类似于 Firebug 的不错的 Google Chrome 扩展程序 我确实看到这里有几个类似的问题 但答案似乎非常过时 Thanks It s built in Press Ctrl Shift I Or Tools gt
  • Apache2 mod_wsgi 403 禁止错误

    我已经正确配置了它 但后来我决定重新安装我的 Debian 顺便从 wheezy 切换到 jessie 版本 问题是这样的 我有一个 python mod wsgi 应用程序 mnt doc Python www index py ls l
  • 如何在 Microsoft Azure 中提取 Blob 存储中的 Blob 的上次修改日期

    我对 MS Azure 的世界还很陌生 我正在尝试使用 Python 获取保存在我的 blob 存储中的一堆文件 块 blob 的文件名和最后修改日期 这是我正在使用的代码 import datetime from azure storag
  • 如何让 list_blobs 表现得像 gsutil

    我只想获得 GCS 上假文件夹结构的第一级 如果我运行例如 gsutil ls gs gcp public data sentinel 2 tiles 我得到一个这样的列表 gs gcp public data sentinel 2 til
  • 如何解析代码(Python)?

    我需要解析一些特殊的数据结构 它们采用某种类似 C 的格式 大致如下所示 Group GroupName C Style comment Group AnotherGroupName Entry some variables 0 3 141
  • 抑制来自 python pandas 描述的名称 dtype

    可以说我有 r pd DataFrame A 1 B pd Series 1 index list range 4 dtype float32 And r B describe mean std min max 给出输出 mean 1 0
  • Pytest - 如何将参数传递给 setup_class?

    我有一些代码 如下所示 我得到了too few args当我运行它时出错 我没有打电话setup class明确地 所以不确定如何向它传递任何参数 我尝试用以下方法装饰该方法 classmethod 但仍然看到相同的错误 我看到的错误是这样
  • Chrome 扩展允许的键盘快捷键

    当您创建 Chrome 浏览器扩展程序时 您可以通过实现来建议键盘快捷键chrome 命令 https developer chrome com extensions commandsAPI 是否有允许的组合键的记录列表 Chrome 似乎
  • 日志处理程序是否使用单独的线程?

    蟒蛇的日志处理程序 http docs python org library logging handlers html都很棒 其中一些 例如SMTP处理程序 http docs python org library logging han
  • Pandas:Drop() int64 基于值返回对象

    我需要删除其中一列低于某个值的所有行 我使用了下面的命令 但这将列作为对象返回 我需要将其保留为int64 df customer id df drop df customer id df customer id lt 9999999 in
  • numpy 沿第一个轴添加

    我想通过简单地沿第一个轴执行相同的加法来添加两个具有不同维度的数组 非矢量化解决方案 x np array 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 shape 4 3 2 y np a
  • Python:使用 FOR 循环插入字典

    我已经在论坛中进行了搜索 但不明白是否可以使用以下构造将新条目插入到我的 Python 字典中 而不将其转换为列表 for x in range 3 pupils dictionary new key input Enter new key
  • 将 2D 数组中的每一列与另一个 2D 数组中的每一列相乘

    我有两个 Numpy 数组x有形状 m i and y有形状 m j 所以行数是相同的 我想将每一列相乘x每一列y逐元素 使结果具有形状 m i j Example import numpy as np np random seed 1 x
  • 将下载的字体添加到 Tkinter

    我想下载一个开源字体并在我的 Python Tkinter 程序中使用它 如何告诉 Tkinter 从目录导入字体或将字体放在与程序相同的文件夹中 Note 我已经寻找答案一段时间了 甚至阅读了 Tkinter 的 API 参考 了解我能找

随机推荐