尝试使用gitlab管道运行基于testcafe硒的测试时超时错误

发布于 2025-02-05 03:54:45 字数 2253 浏览 2 评论 0原文

我创建了一个测试式赛跑者文件,并使用硒网格运行测试。它可以从我的机器上工作正常,但是我们需要使用GitLab管道进行相同的操作。

使用管道,我能够与Selenium Grid Server连接,但始终会出现超时错误。

当我登录Selenium节点服务器进行检查时,我可以看到TestCafe打开Chrome浏览器实例,但无法开始测试。

这是我的管道错误:

Selenium server address is set to: http://myserver:4444/wd/hub
Error: Unable to open the "selenium:chrome" browser due to the following error:
WebDriverError: unknown error: net::ERR_CONNECTION_TIMED_OUT
  (Session info: chrome=102.0.5005.[63](https://gitlab.com/automation-test/load-testing/-/jobs/2556429847#L63))
    at Object.throwDecodedError (/etc/gitlab-runner/builds/1idHsSdk/0/automation-test/load-testing/node_modules/selenium-webdriver/lib/error.js:522:15)
    at parseHttpResponse (/etc/gitlab-runner/builds/1idHsSdk/0/automation-test/load-testing/node_modules/selenium-webdriver/lib/http.js:549:13)
    at Executor.execute (/etc/gitlab-runner/builds/1idHsSdk/0/automation-test/load-testing/node_modules/selenium-webdriver/lib/http.js:475:28)
    at processTicksAndRejections (internal/process/task_queues.js:88:5)
    at Object.execute (/etc/gitlab-runner/builds/1idHsSdk/0/automation-test/load-testing/node_modules/selenium-webdriver/lib/webdriver.js:735:17)
    at BrowserConnection._runBrowser (/etc/gitlab-runner/builds/1idHsSdk/0/automation-test/load-testing/node_modules/testcafe/src/browser/connection/index.ts:214:32)
    at processTicksAndRejections (internal/process/task_queues.js:88:5)

文件

cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
  - node_modules/
  
stages:
   - deploy

e2e_tests:
    stage: deploy  
    tags:
       - shell-executor
    image: node:12.13.0-alpine
    before_script:
      - npm install
    script:
      - node testcafe_runner.js

包。

{
  "name": "TestCafe-TestRunner",
  "version": "0.0.0",
  "license": "MIT",
  "private": true,  
  "devDependencies": {
      "testcafe":"1.18.6",
      "testcafe-browser-provider-selenium":"1.2.0",
      "testcafe-reporter-html":"^1.4.4",
      "testcafe-reporter-xunit":"^2.1.0",
      "find-free-port":"2.0.0",
      "node-cmd":"^3.0.0",
      "internal-ip":"6.2.0",
      "fs-extra":"^6.0.1",
      "csv-parser":"^2.3.2",
      "csv-writer":"^1.6.0"
    }
}

yaml

I created a test-café runner file and running a test using selenium grid. Its working fine from my machine but we need to do same operation using GitLab pipeline.

Using pipeline, I am able to connect with selenium grid server but always getting Time-out error.

When I logged into the selenium node server to check, I can see that testcafe open a chrome browser instance but not able to start the test.

Here is my pipeline error:

Selenium server address is set to: http://myserver:4444/wd/hub
Error: Unable to open the "selenium:chrome" browser due to the following error:
WebDriverError: unknown error: net::ERR_CONNECTION_TIMED_OUT
  (Session info: chrome=102.0.5005.[63](https://gitlab.com/automation-test/load-testing/-/jobs/2556429847#L63))
    at Object.throwDecodedError (/etc/gitlab-runner/builds/1idHsSdk/0/automation-test/load-testing/node_modules/selenium-webdriver/lib/error.js:522:15)
    at parseHttpResponse (/etc/gitlab-runner/builds/1idHsSdk/0/automation-test/load-testing/node_modules/selenium-webdriver/lib/http.js:549:13)
    at Executor.execute (/etc/gitlab-runner/builds/1idHsSdk/0/automation-test/load-testing/node_modules/selenium-webdriver/lib/http.js:475:28)
    at processTicksAndRejections (internal/process/task_queues.js:88:5)
    at Object.execute (/etc/gitlab-runner/builds/1idHsSdk/0/automation-test/load-testing/node_modules/selenium-webdriver/lib/webdriver.js:735:17)
    at BrowserConnection._runBrowser (/etc/gitlab-runner/builds/1idHsSdk/0/automation-test/load-testing/node_modules/testcafe/src/browser/connection/index.ts:214:32)
    at processTicksAndRejections (internal/process/task_queues.js:88:5)

YAML File

cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
  - node_modules/
  
stages:
   - deploy

e2e_tests:
    stage: deploy  
    tags:
       - shell-executor
    image: node:12.13.0-alpine
    before_script:
      - npm install
    script:
      - node testcafe_runner.js

Package.json

{
  "name": "TestCafe-TestRunner",
  "version": "0.0.0",
  "license": "MIT",
  "private": true,  
  "devDependencies": {
      "testcafe":"1.18.6",
      "testcafe-browser-provider-selenium":"1.2.0",
      "testcafe-reporter-html":"^1.4.4",
      "testcafe-reporter-xunit":"^2.1.0",
      "find-free-port":"2.0.0",
      "node-cmd":"^3.0.0",
      "internal-ip":"6.2.0",
      "fs-extra":"^6.0.1",
      "csv-parser":"^2.3.2",
      "csv-writer":"^1.6.0"
    }
}

Any help would be much appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

又怨 2025-02-12 03:54:47

testcafe文档或在图像中安装testcafe,并带有您将要测试的必要浏览器运行时间。

The TestCafe documentation states that you will need to use their docker image, or install testcafe in an image with the necessary browser runtimes you will be testing against.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文