如何解决 Chrome 显示“Aw, Snap!"的问题通过 ChromeDriver 和 Selenium 通过 Python 3 执行测试时的页面 [英] How to address Chrome displaying "Aw, Snap!" page while executing tests through ChromeDriver and Selenium through Python 3

查看:99
本文介绍了如何解决 Chrome 显示“Aw, Snap!"的问题通过 ChromeDriver 和 Selenium 通过 Python 3 执行测试时的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行大约一个小时后,我的 selenium 浏览器将显示Aw,Snap!"页面,我无法从控制台以任何方式与浏览器交互,我必须关闭浏览器并重新启动我的脚本.

After about an hour of running my selenium browser will display an "Aw, Snap!" page, and I am unable to interact with the browser in any way from the console, and I have to close browser and re-start my script.

对此有解释或简单的解决方法吗?

Is there an explanation or easy fix for this?

推荐答案

这个错误画面...

...暗示 ChromeDriver 在加载新的 Browsing ContextChrome 浏览器 会话时遇到问题.

...implies that the ChromeDriver is having problems loading a new Browsing Context i.e. the Chrome Browser session.

您在运行基于 Selenium 测试,由于 /dev/shm/dev/的大小减小,可能会出现此问题shm 空间不足.举个例子:

You are seeing this error about an hour of running Chrome Browser based Selenium tests and this issue can occur due to reduced size of /dev/shm i.e. /dev/shm running out of space. As an example:

mount -o remount,size=64M /dev/shm

理想情况下应该是:

mount --bind /tmp/ /dev/shm/

在 Docker 环境中运行 Chromium 时,64M 大小已大大减少.

While running Chromium in Docker environment 64M size is pretty much reduced state.

根据 Issue 522853: Linux: Chrome/Chromium 中的讨论SIGBUS/噢,快!在小/dev/shm:

  • util_posix.cc:GetShmemTempDir 在 Linux 上尝试始终将 /dev/shm 用于不可执行的内存.
  • /dev/shm所需的大小很大程度上取决于渲染器的数量、屏幕分辨率等.
  • 有时您可能会因为 大型 webapps 而耗尽内存,甚至在 空间不足之前/dev/shm
  • 有时,某些 Docker 容器会决定在默认情况下严格限制其共享内存的大小,这对于某些工作负载来说可能没问题,并且可能会阻止任何容器占用所有内存.
  • util_posix.cc:GetShmemTempDir on Linux attempts to always use /dev/shm for non-executable memory.
  • The required size of /dev/shm by large depends on the number of renderers, screen resolution, etc.
  • At time you may run out of memory due to large webapps even before running out of space in /dev/shm
  • At times some Docker containers decides to severely limit the size of their shared memory by default, which may be ok for some workloads, and probably prevents any container from hogging all the memory.

在以下讨论中详细分析和讨论了这个问题:

This issue was analyzed and discussed at length in the following discussions:

这个问题最终通过 commit/revision 通过修复 CreateAnonymousSharedMemory() 不泄漏文件时返回 fd.

This issue was finally addressed through the commit / revision by fixing CreateAnonymousSharedMemory() not to leak FILE when returning fd.

CreateAnonymousSharedMemory() 已修改为将可写内存句柄作为文件描述符而不是作为文件返回.由于 POSIX 不提供在不关闭()底层文件描述符的情况下拆卸 FILE 的标准方法,因此这是通过泄漏 FILE 来实现的.我们现在提供 CreateAndOpenFdForTemporaryFileInDir(),以避免将临时文件描述符包装到 FILE 中.

CreateAnonymousSharedMemory() was modified to return the writable memory handle as a file-descriptor rather than as a FILE. Since POSIX does not provide a standard way to teardown a FILE without also close()ing the underlying file-descriptor, this was achieved by leaking the FILE. We now provide CreateAndOpenFdForTemporaryFileInDir(), to avoid the need to wrap the temporary-file descriptor into a FILE at all.

<小时>

结论

确保:

  • /dev/shm/ 挂载了足够的内存.
  • Selenium 已升级到当前级别版本 3.141.59.
  • ChromeDriver 已更新为当前 ChromeDriver v79.0.3945.36 级别.
  • Chrome 已更新至当前 Chrome 版本 79.0 级别.(根据 ChromeDriver v78.0 发行说明)
  • 清理你的项目工作区通过你的IDE重建你的项目只需要依赖.
  • 如果您的基础 Web Client 版本太旧,请通过 卸载它Revo Uninstaller 并安装最新的 GA 和发布版本的 Web Client.
  • 进行一次系统重启.
  • 非 root 用户身份执行您的 @Test.
  • /dev/shm/ is mounted with enough memory.
  • Selenium is upgraded to current levels Version 3.141.59.
  • ChromeDriver is updated to current ChromeDriver v79.0.3945.36 level.
  • Chrome is updated to current Chrome Version 79.0 level. (as per ChromeDriver v78.0 release notes)
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
  • Take a System Reboot.
  • Execute your @Test as non-root user.

这篇关于如何解决 Chrome 显示“Aw, Snap!"的问题通过 ChromeDriver 和 Selenium 通过 Python 3 执行测试时的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆