【问题标题】:How to run WebdriverIO tests with GitHub Actions?如何使用 GitHub Actions 运行 WebdriverIO 测试?
【发布时间】:2021-03-20 04:30:41
【问题描述】:

我们实际上正在将我们的存储库移动到 github,并且我们希望将 github 操作用于我们的管道,以及我们基于 WebdriverIO 的测试自动化框架。我对 github 操作完全陌生,我更擅长 Jenkins 和 Jenkins 管道。

所以,WebdriverIO webpage 上有一个非常小的 github 操作示例,但它对我们/我并没有真正的帮助。我尝试只执行一些测试,将一些东西推送到分支。我们目前正在“ubuntu-latest”图像上运行它,我尝试只执行一些简单的网络测试,但这并不容易。我一开始尝试了以下几种方式:

  1. 直接在ubuntu-latest镜像上使用chromedriver执行测试会报错:

    ERROR webdriver: Request failed with status 500 due to unknown error: unknown error: Chrome failed to start: exited abnormally.

  2. 将 wdio docker 服务与 docker 映像“selenium/standalone-chrome-debug”一起使用也会产生错误。如果我重新运行这项工作,那么一切都很好。第一次运行也是一个问题,第一次运行更有趣;):

    ERROR wdio-docker-service: Failed to run container: request to http://localhost:4444/ failed, reason: connect ECONNREFUSED 127.0.0.1:4444

也许您有一些经验、建议或示例可以让我解决这个问题?通过 GitHub 操作执行 WebdriverIO 测试的最佳方式是什么?

这是我的 github 操作工作流 yaml:

name: Testautomation Example

on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Setup
        run: npm install
      - name: Test
        # 1. issue with chromedriver
        #run: ENV_PATH=environment/QS npm run clear-test -- "wdio-configs/wdio.conf.chrome.chromedriver.js --cucumberOpts.tagExpression=@example"
        # 2. issue with wdio docker service
        run: ENV_PATH=environment/QS npm run clear-test -- "wdio-configs/wdio.conf.chrome.docker.debug.js --cucumberOpts.tagExpression=@example"
      - name: Upload Test Reports
        uses: actions/upload-artifact@v2
        with:
          name: reports
          path: tests/reports/
      - name: Upload Logs
        uses: actions/upload-artifact@v2
        with:
          name: logs
          path: log/

【问题讨论】:

标签: selenium github webdriver github-actions webdriver-io


【解决方案1】:

我已经解决了我的问题,这是 github 操作的示例 github 工作流:

name: Multiple Environments Example

on: [push, pull_request]

jobs:
  e2e-test-on-ubuntu-with-local-chrome:
    runs-on: ubuntu-latest
    #runs-on: macos-latest
    #runs-on: windows-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Setup
        run: npm install
      - name: Test
        run: npm run clear-test -- "wdio-configs/wdio.conf.chrome.chromedriver.headless.js --cucumberOpts.tagExpression=@myTests"
        env:
          ENV_PATH: environment/QS
      - name: Upload Test Reports
        uses: actions/upload-artifact@v2
        with:
          name: reports
          path: tests/reports/
      - name: Upload Logs
        uses: actions/upload-artifact@v2
        with:
          name: logs
          path: log/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-29
    • 2022-07-26
    • 2021-06-25
    • 1970-01-01
    • 1970-01-01
    • 2021-04-23
    相关资源
    最近更新 更多