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

未知错误:会话被删除,因为选项卡崩溃导致页面崩溃

梁晋鹏
2023-03-14

注意:我的问题被关闭之前,我尝试了这里提到的解决方案-未知错误:会话删除,因为页面崩溃从未知错误:无法确定加载状态从标签崩溃与ChromeDriver硒-添加这些选项-options.add参数("--disable-dev-shm-用法");options.add参数("--no-沙盒"); -- 我仍然看到的问题

在selenium网格中运行时,在某些情况下,单个测试会出现以下错误:

方法1:

org.openqa.selenium.WebDriverException: unknown error: session deleted because of page crash
from tab crashed
  (Session info: chrome=80.0.3987.106)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'DESKTOP-37JVVAA', ip: '169.254.210.134', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 80.0.3987.106, chrome: {chromedriverVersion: 80.0.3987.106 (f68069574609..., userDataDir: /tmp/.com.google.Chrome.TQ7Z9v}, goog:chromeOptions: {debuggerAddress: localhost:41695}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: none, platform: LINUX, platformName: LINUX, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webdriver.remote.sessionid: 2ac66b1a001b0b8c6c24da9821b...}
Session ID: 2ac66b1a001b0b8c6c24da9821b8f1e2

钩子方法2:

org.openqa.selenium.NoSuchSessionException: invalid session id
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'DESKTOP-37JVVAA', ip: '169.254.210.134', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 80.0.3987.106, chrome: {chromedriverVersion: 80.0.3987.106 (f68069574609..., userDataDir: /tmp/.com.google.Chrome.TQ7Z9v}, goog:chromeOptions: {debuggerAddress: localhost:41695}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: none, platform: LINUX, platformName: LINUX, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webdriver.remote.sessionid: 2ac66b1a001b0b8c6c24da9821b...}
Session ID: 2ac66b1a001b0b8c6c24da9821b8f1e2

钩子方法3:

org.openqa.selenium.WebDriverException: Session [2ac66b1a001b0b8c6c24da9821b8f1e2] was terminated due to BROWSER_TIMEOUT
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'DESKTOP-37JVVAA', ip: '169.254.210.134', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 80.0.3987.106, chrome: {chromedriverVersion: 80.0.3987.106 (f68069574609..., userDataDir: /tmp/.com.google.Chrome.TQ7Z9v}, goog:chromeOptions: {debuggerAddress: localhost:41695}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: none, platform: LINUX, platformName: LINUX, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webdriver.remote.sessionid: 2ac66b1a001b0b8c6c24da9821b...}
Session ID: 2ac66b1a001b0b8c6c24da9821b8f1e2

在hooks中我们有3种顺序方法——看起来第一个问题是根本原因,但我不确定。

以下是用于驱动程序的选项:

            ChromeOptions options = new ChromeOptions();
            options.addArguments("start-maximized");
            options.addArguments("--disable-infobars");
            options.addArguments("--disable-extensions");
            options.addArguments("chrome.switches", "--disable-extensions");
            options.addArguments("--disable-gpu");
            options.addArguments("--disable-dev-shm-usage");
            options.addArguments("--no-sandbox");
            options.addArguments("--disable-notifications");
            options.addArguments("--disable-popup-blocking");
            options.addArguments("enable-automation");
            options.addArguments("--disable-dev-shm-usage");
            options.addArguments("--disable-browser-side-navigation");
            options.addArguments("--dns-prefetch-disable");
            options.setPageLoadStrategy(PageLoadStrategy.NONE);
            options.setExperimentalOption("useAutomationExtension", false);
            driver = new RemoteWebDriver(new URL(AWS_URL), options);

以下是我们在kubernetest yaml文件中使用的覆盖:

  chrome:
    ## Enable the creation of a node-chrome pod
    enabled: true
    replicas: 65
    javaOpts: "-Xmx1024m -XX:+UseSerialGC"
    resources:
      limits:
        cpu: ".5"
        memory: "1000Mi"
    env:
      sessionTimeout: 60
  hub:
    env:
      sessionTimeout: 60
    ##gridBrowserTimeout
    gridBrowserTimeout: 240
    livenessTimeout: 15
    readinessTimeout: 15
    gridJettyMaxThreads: 1024
    gridTimeout: 60
    gridCleanUpCycle: 5000
    gridNewSessionWaitTimeout: -1
    javaOpts: "-Xmx1024m -XX:+UseSerialGC"

    ## ref: http://kubernetes.io/docs/user-guide/compute-resources/
    resources:
      limits:
        cpu: "3"
        memory: "2048Mi"
 Please help

共有2个答案

谭泳
2023-03-14

我对Chrome和Firefox也有同样的问题。我可以通过增加两个容器的大小(shm_size)来解决这个问题。

version: "3"
services:
  hub:
    image: selenium/hub
    ports:
      - "4444:4444"
  chrome:
    image: selenium/node-chrome
    shm_size: '1gb'
    depends_on:
      - hub
    environment:
      - HUB_HOST=hub
  firefox:
    image: selenium/node-firefox
    shm_size: '1gb'
    depends_on:
      - hub
    environment:
      - HUB_HOST=hub
叶国兴
2023-03-14

我也遇到了同样的问题,通过在docker compose中为chrome容器添加-/dev/shm:/dev/shm解决了这个问题。yml文件
参考:https://github.com/SeleniumHQ/docker-selenium

chrome:
 image: selenium/node-chrome
 depends_on:
  - selenium-hub
 volumes:
  - /dev/shm:/dev/shm
 environment:
  HUB_PORT_4444_TCP_ADDR: selenium-hub
  HUB_PORT_4444_TCP_PORT: 4444
  NODE_MAX_SESSION: 2
  NODE_MAX_INSTANCES: 2
 类似资料:
  • 我正在使用InstaPy,它使用Python和Selenium。我按Cron启动脚本,有时会崩溃。所以它是非常不规则的,有时它运行良好。我已经在GitHub Repo上发布了,但没有得到回复,所以我现在在这里问,是否有人知道为什么。 这是一个数字海洋ubuntu服务器,我在无头模式下使用它。驱动程序版本在日志上可见。以下是错误消息: 你知道原因是什么,怎么解决吗? 谢谢你的意见。http://tr

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

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

  • Python 3.5。2. Ubuntu 16.04 LTS 尝试使用pip3安装某些软件包时,无论参数如何,它都会返回以下结果: 我试图通过以下方式重新安装python3 pip来修复它: 但那没有帮助。 我发现它与我安装的软件包有关,这些软件包是用

  • 我到底想做什么? 尝试有一个码头工人的形象,做以下。是的,我知道有其他方法来完成这里的最终游戏,但我有一个具体的要求。 运行一个ASP。NET MVC 4.5网络应用程序 当前状态-在常规Windows 10或Windows 2016中运行测试时,测试运行正常。当测试在Windows docker容器中运行时,会显示“由于页面崩溃而删除会话”。请注意,我关注的是chrome测试,但我们在使用Fir

  • 在我的应用程序主页中,auto complete在对话框栏内的按钮上打开,该位置用于搜索查询。问题是,当我尝试通过再次按下按钮来更改位置时,应用程序崩溃,出现以下错误。 这是按钮按活动及其调用的方法。 下面是xml代码 以下是logcat 我已经研究了很多问题,几乎所有的答案都是在中添加一些代码行,而我没有这些代码行。在第一次点击片断的时候,问题是当我再次按下按钮来改变应用程序完全粉碎的位置。欢迎