当前位置: 首页 > 知识库问答 >
问题:

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

戚飞雨
2023-03-14

我正在使用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/的人帮了我。

共有3个答案

吕鸿朗
2023-03-14

我在Ubuntu服务器上遇到以下错误:

硒。常见的例外。WebDriverException:消息:未知错误:由于页崩溃,会话从选项卡崩溃中删除(会话信息:headless chrome=86.0.4240.111)(驱动程序信息:chromedriver=2.41.578700(2f1ed5f9343c13f73144538f15c00b370eda6706),平台=Linux 5.4.0-1029-aws x86_64)

事实证明,错误的原因是服务器上的磁盘空间不足,解决方案是扩展我的磁盘空间。你可以查看这个问题以了解更多信息。

贡光明
2023-03-14

如果有人在docker容器中遇到此问题:

创建容器时使用标志--shm size=2g,错误消失。此标志使容器使用主机的共享内存。

示例

$ docker run -d --net gridNet2020 --shm-size="2g" -e SE_OPTS="-browser applicationName=zChromeNodePdf30,browserName=chrome,maxInstances=1,version=78.0_debug_pdf" -e HUB_HOST=selenium-hub-3.141.59 -P -p 5700:5555 --name zChromeNodePdf30 -v /var/lib/docker/sharedFolder:/home/seluser/Downloads selenium/node-chrome:3.141.59-xenon

来源:https://github.com/SeleniumHQ/docker-selenium

乔俊才
2023-03-14

尽管您认为错误如下:

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

你的代码测试会给我们一些出错的线索。

这个问题有不同的解决方案。然而,根据未知错误:由于标签页崩溃而删除的会话,这个问题可以通过以下任何一种解决方案来解决:

>

  • 添加以下chrome_options

    chrome_options.add_argument('--no-sandbox')         
    

    Chrome似乎在某些页面上的Docker容器中崩溃,因为太小了/dev/shm。因此,您可能需要修复较小的/dev/shm大小。

    一个例子:

    sudo mount -t tmpfs -o rw,nosuid,nodev,noexec,relatime,size=512M tmpfs /dev/shm
    

    如果使用-v/dev/shm:/dev/shm选项共享主机/dev/shm

    另一种方法是将chrome_options添加为--disable-dev-shm-use。这将迫使Chrome使用/tmp目录。这可能会减慢执行速度,因为磁盘将被使用而不是内存。

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

    从选项卡崩溃是WIP(工作进行中)与Chromium团队相当一段时间,现在涉及Linux试图总是使用 /dev/shm的非可执行内存。以下是参考文献:

    • Linux:Chrome/Chromium SIGBUS/Aw,Snap!在small/dev/shm上
    • 当/dev/shm太小且无法覆盖位置时,Chrome崩溃/无法加载
    • 根据评论61#第736452期,修复程序似乎已与Chrome v65一起发布。0.3299.6

    你可以在以下网站上找到一些相关的讨论:

    • org.openqa.selenium.SessionNotCreatedExcture:会话未创建异常从选项卡崩溃错误时,从Jenkins CI服务器执行

  •  类似资料:
    • 问题可能是内存使用。页面开始变得非常慢,在某个时候出现以下错误消息 下面是一些我浏览过的类似问题的链接,我尝试添加选项,但不起作用。其他一些技巧真的让我困惑,所以我希望有人能在这里帮助我(我对编码很陌生) 以下是我浏览的链接 未知错误:会话被删除,因为选项卡崩溃导致页面崩溃 python linux selenium:无法访问chrome 未知错误:由于未知错误导致页面崩溃,会话被删除:无法从Ch

    • 注意:我的问题被关闭之前,我尝试了这里提到的解决方案-未知错误:会话删除,因为页面崩溃从未知错误:无法确定加载状态从标签崩溃与ChromeDriver硒-添加这些选项-options.add参数("--disable-dev-shm-用法");options.add参数("--no-沙盒"); -- 我仍然看到的问题 在selenium网格中运行时,在某些情况下,单个测试会出现以下错误: 方法1:

    • 问题内容: 我正在使用使用Python和Selenium的InstaPy。我每个Cron都会启动脚本,并且有时会崩溃。所以它确实是不规则的,有时运行得很好。我也已经在GitHub Repo上发布了消息,但是在那儿没有得到答案,所以我现在在这里问是否有人知道为什么。 这是一台数字海洋ubuntu服务器,我在无头模式下使用它。驱动程序版本在日志中可见。这是错误消息: 知道原因可能是什么以及如何解决?

    • 问题内容: 我正在尝试使用ChromeWebDriver在Chrome上测试我的应用程序,但是每次尝试都会出现以下异常: 在chromedriver.log中,我看到了 我正在使用: 镀铬36 ChromeWebDriver 2.10 Windows 7的 在Process Explorer中,我可以看到chromedriver.exe进程正在运行,但是没有打开任何窗口,几秒钟后,我得到了上面的异

    • 我有这个代码和一个执行中的问题(代码下的描述) 我使用: Ubuntu 14.04.5 LTS 当我创建RemoteWebDriver时,我得到以下错误:异常:未知错误:Chrome无法启动:崩溃 启动selenium服务器的命令 此方案的哪些部分可能是所述错误的原因?

    • 我试图将与一起使用,我为chromedriver到/usr/local/bin的路径创建了一个符号链接,但当我运行 我的错误是 它还会生成一个核心。******,一个包含五个随机数的核心文件点,大小超过200MB。 版本: 有谁能帮我找出问题出在哪里吗?