【问题标题】:WebdriverIO doesn't spawn a browser in CircleCI jobWebdriverIO 不会在 CircleCI 作业中生成浏览器
【发布时间】:2021-10-21 22:55:36
【问题描述】:

我正在尝试在 CircleCi 中运行我的 E2E 测试。测试在本地工作。 在 wdio 调用之后,CircleCi 测试卡住了:

[0-0] 2021-08-20T11:01:17.873Z INFO webdriver: Initiate new session using the WebDriver protocol
[0-0] 2021-08-20T11:01:17.902Z INFO webdriver: [POST] http://localhost:9515/session
[0-0] 2021-08-20T11:01:17.902Z INFO webdriver: DATA {
[0-0]   capabilities: {
[0-0]     alwaysMatch: {
[0-0]       browserName: 'chrome',
[0-0]       'goog:chromeOptions': [Object],
[0-0]       acceptInsecureCerts: true
[0-0]     },
[0-0]     firstMatch: [ {} ]
[0-0]   },
[0-0]   desiredCapabilities: {
[0-0]     browserName: 'chrome',
[0-0]     'goog:chromeOptions': { args: [Array] },
[0-0]     acceptInsecureCerts: true
[0-0]   }
[0-0] }

在本地,在此请求之后遵循在浏览器中打开 url 的命令。 但对我来说,它会抛出这样的超时错误:

[0-0] 2021-08-20T11:03:18.009Z WARN webdriver: Request timed out! Consider increasing the "connectionRetryTimeout" option.

这是我的 CI 配置文件:

version: 2.1
orbs:
  browser-tools: circleci/browser-tools@1.2.1
jobs:
  e2e:
    working_directory: /tmp/circle-run
    docker:
      - image: cimg/node:14.16.1-browsers
    resource_class: large
    steps:
      - browser-tools/install-chrome
      - browser-tools/install-chromedriver
      - checkout
      - run:
          name: Install Node Modules
          command: npm ci
      - save_cache:
          key: dependency-cache-{{ .Environment.CACHE_VERSION }}-{{ checksum 
 "package.json" }}-{{checksum "package-lock.json" }}
          paths:
            - ./node_modules
      - run:
          name: lint
          command: npm run lint
      - run:
          name: Run E2E tests on staging
          command: npm run test:e2e
      - store_test_results:
          path: tests/wdio-e2e/allure-results
// ETC

我使用 chromedriver-service 运行 WebdriverIO。

我认为问题不在于访问互联网,因为我尝试使用 Selenium Standalone 服务解决此问题,并且能够 curl 一个 jar 文件。 我做错了什么?

谢谢。

【问题讨论】:

    标签: ui-automation circleci qa webdriver-io


    【解决方案1】:

    问题出在 wdio.config.js 和 async before() 函数上。在玩设置时忘记删除它。

    async beforeTest() 和 async afterTest() 函数可以安全地保留在配置文件中 - 它们不会造成任何问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多