版本 93 中的 ChromeDriver 会话超时

ChromeDriver Session Timeouts in version 93

Chrome 93 最近发布了。大约在这个时候(8 月 31 日中部下午 4 点),我们的端到端测试开始失败。这些测试利用 Protractor,它们通过 TeamCity 运行 在安装了 Chrome 93 的 Windows 构建代理上进行。

我们已尝试强制使用 93.x 和 92.x 版本的 chromedriver。两者都在下面产生这个超时。我们可以 运行 在本地毫无问题地进行这些 e2e 测试。有什么建议吗?

[10:23:38] I/launcher - Running 1 instances of WebDriver
10:23:38   [10:23:38] I/direct - Using ChromeDriver directly...
10:33:40   [10:33:40] E/launcher - session not created
10:33:40   from timeout: Timed out receiving message from renderer: 600.000
10:33:40     (Session info: chrome=93.0.4577.63)
10:33:40     (Driver info: chromedriver=93.0.4577.15 (660fc11082ba57405eca2e8c49c3e1af756fbfae-refs/branch-heads/4577@{#203}),platform=Windows NT 10.0.14393 x86_64)
10:33:40   [10:33:40] E/launcher - SessionNotCreatedError: session not created
10:33:40   from timeout: Timed out receiving message from renderer: 600.000
10:33:40     (Session info: chrome=93.0.4577.63)
10:33:40     (Driver info: chromedriver=93.0.4577.15 (660fc11082ba57405eca2e8c49c3e1af756fbfae-refs/branch-heads/4577@{#203}),platform=Windows NT 10.0.14393 x86_64)
10:33:40       at Object.checkLegacyResponse (C:\BuildAgent\work\f3ee5d88fcfb5472\node_modules\selenium-webdriver\lib\error.js:546:15)
10:33:40       at parseHttpResponse (C:\BuildAgent\work\f3ee5d88fcfb5472\node_modules\selenium-webdriver\lib\http.js:509:13)
10:33:40       at C:\BuildAgent\work\f3ee5d88fcfb5472\node_modules\selenium-webdriver\lib\http.js:441:30
10:33:40       at processTicksAndRejections (internal/process/task_queues.js:93:5)
10:33:40   From: Task: WebDriver.createSession()
10:33:40       at Function.createSession (C:\BuildAgent\work\f3ee5d88fcfb5472\node_modules\selenium-webdriver\lib\webdriver.js:769:24)
10:33:40       at Function.createSession (C:\BuildAgent\work\f3ee5d88fcfb5472\node_modules\selenium-webdriver\chrome.js:761:15)
10:33:40       at Direct.getNewDriver (C:\BuildAgent\work\f3ee5d88fcfb5472\node_modules\protractor\built\driverProviders\direct.js:77:33)
10:33:40       at Runner.createBrowser (C:\BuildAgent\work\f3ee5d88fcfb5472\node_modules\protractor\built\runner.js:195:43)
10:33:40       at C:\BuildAgent\work\f3ee5d88fcfb5472\node_modules\protractor\built\runner.js:339:29
10:33:40       at _fulfilled (C:\BuildAgent\work\f3ee5d88fcfb5472\node_modules\protractor\node_modules\q\q.js:834:54)
10:33:40       at C:\BuildAgent\work\f3ee5d88fcfb5472\node_modules\protractor\node_modules\q\q.js:863:30
10:33:40       at Promise.promise.promiseDispatch (C:\BuildAgent\work\f3ee5d88fcfb5472\node_modules\protractor\node_modules\q\q.js:796:13)
10:33:40       at C:\BuildAgent\work\f3ee5d88fcfb5472\node_modules\protractor\node_modules\q\q.js:556:49
10:33:40       at runSingle (C:\BuildAgent\work\f3ee5d88fcfb5472\node_modules\protractor\node_modules\q\q.js:137:13)
10:33:40   [10:33:40] E/launcher - Process exited with error code 199

这不是完全相同的 question/situation,但是 this SO post 中有很多有用的见解。

我们正在使用量角器,所以对我们来说,解决方法是在下面添加 --disable-gpu 参数,上面的 SO post.

中也暗示了这一点
  chromeOptions: {
    args: [
      '--disable-gpu'
    ]
  }

不确定为什么我们在 Chrome 93 时需要它,但它也列在 Protractor browser setup 中(声称它在 Chrome 58 时需要)。

As of Chrome 58 you also need to set --disable-gpu, though this may change in future versions.

我能够尝试使用以下选项解决问题(不太好,但它有效...):

    chromeOptions.addArguments("no-sandbox");
    chromeOptions.addArguments("disable-infobars");
    chromeOptions.addArguments("disable-dev-shm-usage");
    chromeOptions.addArguments("disable-browser-side-navigation");
    chromeOptions.addArguments("disable-gpu");
    chromeOptions.addArguments("--dns-prefetch-disable");
    chromeOptions.addArguments("disable-extensions");
    chromeOptions.addArguments("force-device-scale-factor=1");
    chromeOptions.setPageLoadStrategy(PageLoadStrategy.NORMAL);
    chromeOptions.addArguments("enable-features=NetworkServiceInProcess");
    chromeOptions.addArguments("--aggressive-cache-discard");
    chromeOptions.addArguments("--disable-cache");
    chromeOptions.addArguments("--disable-application-cache");
    chromeOptions.addArguments("--disable-offline-load-stale-cache");

    chromeOptions.addArguments("start-maximized");
    chromeOptions.addArguments("lang=de");
    chromeOptions.addArguments("allow-running-insecure-content");
    chromeOptions.addArguments("inprivate");