首页 > 解决方案 > 带有 CicrcleCI 的 WebdriverIO-chromedriver 版本出错

问题描述

我正在尝试在 CircleCI 上使用黄瓜框架运行 webdriverIO 测试,但是在执行测试命令时遇到了问题-

这是我正在使用的 circleCI config.yml -

version: 2.1

jobs:
  build:
    docker:
    
    - image: circleci/node:10-browsers
    working_directory: ~/project
     
    steps:
      - checkout
      - restore_cache:
          keys:
            - v1-dependencies-{{ checksum "package.json" }}
            # fallback to using the latest cache if no exact match is found
            - v1-dependencies-

      - run:
          name: "Install dependencies"
          command: |
            npm install
      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}

      - run:
          name: "Run tests"
          command: |
           npm run test


      - store_test_results:
          path: ./allure-results

这是我的 wdio.conf.js-

exports.config = {
    //
    // ====================
    // Runner Configuration
    // ====================
    //
    // WebdriverIO allows it to run your tests in arbitrary locations (e.g. locally or
    // on a remote machine).
    runner: 'local',
    hostname: 'localhost',
    port: 4444,
   
    specs: [
        './features/**/*.feature'
    ],
    // Patterns to exclude.
    exclude: [
        // 'path/to/excluded/files'
    ],
   
    maxInstances: 10,
    
    capabilities: [{
    
       
        maxInstances: 5,
        browserName: 'chrome',
        acceptInsecureCerts: true
       
    }],
    
    logLevel: 'info',
   
    bail: 0,
   
    baseUrl: 'http://localhost',
    
    waitforTimeout: 10000,
   
    connectionRetryTimeout: 120000,
    
    connectionRetryCount: 3,
    
    services: ['selenium-standalone'],
  capabilities: [{
    maxInstances: 5,
    browserName: 'chrome',
  }],
  args: {
    drivers: {
        chrome: { version: '83.0.4103' },
     
    }
},



   framework: 'cucumber',
   
    reporters: ['spec','allure'],
    reporterOptions: {
        allure: {
            outputDir: './reports/allure-results'
        }

    },

 
    cucumberOpts: {
        require: ['./features/step-definitions/steps.js'],
        backtrace: false,
        requireModule: ['@babel/register'],
        dryRun: false,
        failFast: false,

formatter output (repeatable) format: ['pretty'], // 隐藏待处理步骤的步骤定义片段 snippets: true, // 隐藏源 uris source: true, // <string[]> (name) 指定要使用的配置文件profile: [], // 如果有任何未定义或待处理的步骤则失败 strict: false, // (表达式) 仅执行与表达式匹配的标签的功能或场景 tagExpression: '@runnow1', // 步骤定义超时 timeout : 60000, // 启用此配置以将未定义的定义视为警告。忽略未定义定义:假},

}


This is the stack trace of the error I am getting in circleCi-

[0-2] 2020-08-27T14:09:27.770Z ERROR webdriver: session not created: session not created: This version of ChromeDriver only supports Chrome version 83
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'f5e174502751', ip: '172.19.0.3', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-1077-aws', java.version: '11.0.6'
Driver info: driver.version: unknown
remote stacktrace: #0 0x561324a36579 <unknown>

    at getErrorFromResponseBody (/home/circleci/project/node_modules/webdriver/build/utils.js:121:10)
    at WebDriverRequest._request (/home/circleci/project/node_modules/webdriver/build/request.js:149:56)
    at process._tickCallback (internal/process/next_tick.js:68:7)
[0-2] 2020-08-27T14:09:27.770Z ERROR @wdio/runner: Error: Failed to create session.
session not created: This version of ChromeDriver only supports Chrome version 83
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'f5e174502751', ip: '172.19.0.3', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-1077-aws', java.version: '11.0.6'
Driver info: driver.version: unknown
remote stacktrace: #0 0x561324a36579 <unknown>

    at startWebDriverSession (/home/circleci/project/node_modules/webdriver/build/utils.js:45:11)
    at process._tickCallback (internal/process/next_tick.js:68:7)
[0-2]  Error:  Failed to create session.
session not created: This version of ChromeDriver only supports Chrome version 83
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'f5e174502751', ip: '172.19.0.3', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-1077-aws', java.version: '11.0.6'
Driver info: driver.version: unknown
remote stacktrace: #0 0x561324a36579 <unknown>

标签: circleciwebdriver-io

解决方案


这是 WebdriverIO 用于下载正确版本的 Chromedriver 的依赖项的最近回归。WebdriverIO 问题在这里

该问题中建议的临时解决方法是告诉 selenium-service 在 wdio 配置中使用特定版本的 Chromedriver:

services: [
    [
      "selenium-standalone",
      {
        logPath: "logs",
        installArgs: {
          version: "3.141.5",
          baseURL: "https://selenium-release.storage.googleapis.com",
          drivers: {
            chrome: {
              version: "85.0.4183.83",
              arch: process.arch,
              baseURL: "https://chromedriver.storage.googleapis.com",
            },
          },
        },
        args: {
          version: "3.141.5",
          drivers: {
            chrome: {
              version: "85.0.4183.83",
              arch: process.arch,
            },
          },
        },
      },
    ],
],

推荐阅读