【问题标题】:How to run two different wdio.config.js file one after another如何一个接一个地运行两个不同的 wdio.config.js 文件
【发布时间】:2020-04-26 06:48:17
【问题描述】:

我目前有两个配置不同的 wdio.config.js 文件。我怎样才能一个接一个地运行?有可能吗?

这是我在代码中定义的方式:

第一个 config.js

const { join } = require('path');
require('@babel/register')

exports.config = {
    maxInstances: 3,
    runner: 'local',
    //
    specs: [
        './tests/specs/**/*.spec.js'
    ],
    //
    exclude: [
        // 'path/to/excluded/files'
    ],
    //
    //
    baseUrl: 'http://localhost:9174/',

    capabilities: {
        chromeBrowser: {
            capabilities: {
                browserName: 'chrome'
            }
        },
        App: {
            port: 4723,
            capabilities: {
                platformName: 'iOS',
                'appium:platformVersion': '12.4',
                'appium:orientation': 'PORTRAIT',
                'appium:noReset': true,
                'appium:newCommandTimeout': 240,
                "appium:platformName": "iOS",
                "appium:deviceName": "iPhone 8",
                "appium:bundleId": "com.app.debug",
            }
        },
    },

    services: ['appium'],
    /* appium: {

        args: {
            address: '127.0.0.1',
        }
    }, */

    //
    //logLevel: 'trace',
    //
    //deprecationWarnings: true,
    //
    //bail: 0,
    //
    waitforTimeout: 20000,
    //
    //connectionRetryTimeout: 90000,
    //
    //connectionRetryCount: 3,
    //
    services: ['selenium-standalone'],
    //
    //framework: 'jasmine',
    /* jasmineNodeOpts: 
    {   
    // Jasmine default timeout
    defaultTimeoutInterval: 60000,
    expectationResultHandler(passed, assertion) 
    {
      // do something
    }, */

    //
    //
}

第二个config.js

const { join } = require('path');
require('@babel/register')

exports.config = {
    runner: 'local',
    //
    specs: [
        './tests/specs/**/*.common.js'
    ],
    //
    exclude: [
        // 'path/to/excluded/files'
    ],
    //
    //

    capabilities: {

        App: {
            port: 4724,
            capabilities: {
                platformName: 'iOS',
                'appium:platformVersion': '13.2',
                'appium:orientation': 'PORTRAIT',
                'appium:noReset': true,
                'appium:newCommandTimeout': 240,
                "appium:deviceName": "iPhone 11",
                "appium:bundleId": "com.xyz.debug",
            }
        }
    },

    services: ['appium'],
    /* appium: {

        args: {
            address: '127.0.0.1',
        }
    }, */

    //
    //logLevel: 'trace',
    //
    //deprecationWarnings: true,
    //
    //bail: 0,
    //
    waitforTimeout: 20000,
    //
    //connectionRetryTimeout: 90000,
    //
    //connectionRetryCount: 3,
    //
    services: ['selenium-standalone'],
    //
    //framework: 'jasmine',
    /* jasmineNodeOpts: 
    {   
    // Jasmine default timeout
    defaultTimeoutInterval: 60000,
    expectationResultHandler(passed, assertion) 
    {
      // do something
    }, */

    //
    //
}

还有我的 package.json 文件:

{
  "type": "module",
  "name": "appium-boilerplate",
  "version": "5.3.1",
  "description": "Run end to end tests with using the webapp and the mobile app",
  "scripts": {
    "android.sauce.rdc.app": "./node_modules/.bin/wdio ./config/saucelabs/wdio.android.rdc.app.conf.js",
    "consumer.app": "./node_modules/.bin/wdio ./config/wdio.consumer.app.conf.js",
    "android.browser": "./node_modules/.bin/wdio ./config/wdio.android.browser.conf.js",
    "ios.app": "./node_modules/.bin/wdio ./config/wdio.ios.app.conf.js",
    "ios.sauce.rdc.app": "./node_modules/.bin/wdio ./config/saucelabs/wdio.ios.rdc.app.conf.js",
    "ios.browser": "./node_modules/.bin/wdio ./wdio.conf.js",
    "real.browser": "./node_modules/.bin/wdio ./config/wdio.browser.conf.js",
    "lint": "eslint config tests",
    "build": "babel --presets es2015 -d lib/ src"
  },
  "dependencies": {
    "@babel/runtime": "^7.7.6",
    "esm": "^3.2.25"
  },
  "devDependencies": {
    "@babel/cli": "^7.7.5",
    "@babel/core": "^7.7.5",
    "@babel/preset-env": "^7.7.6",
    "@babel/preset-react": "^7.7.4",
    "@babel/register": "^7.7.4",
    "@babel/traverse": "^7.5.5",
    "@babel/types": "^7.5.5",
    "@wdio/appium-service": "^5.12.1",
    "@wdio/cli": "^5.12.4",
    "@wdio/jasmine-framework": "^5.16.15",
    "@wdio/local-runner": "^5.16.15",
    "@wdio/mocha-framework": "^5.16.15",
    "@wdio/sauce-service": "^5.12.1",
    "@wdio/selenium-standalone-service": "5.6.4",
    "@wdio/spec-reporter": "^5.16.11",
    "@wdio/sync": "^5.16.15",
    "appium": "^1.13.0",
    "babel-core": "^7.0.0-bridge.0",
    "babel-eslint": "^10.0.2",
    "chromedriver": "^78.0.1",
    "eslint": "^5.16.0",
    "eslint-config-standard": "^12.0.0",
    "eslint-plugin-import": "^2.18.2",
    "eslint-plugin-node": "^7.0.1",
    "eslint-plugin-promise": "^4.2.1",
    "eslint-plugin-standard": "^4.0.1",
    "eslint-plugin-wdio": "^5.12.1",
    "mocha": "^6.2.2",
    "node-fetch": "^2.3.0",
    "spectron": "^9.0.0",
    "wdio-chromedriver-service": "^5.0.2",
    "webdriverio": "^5.12.4"
  }
}

我想用一个命令运行第一个然后第二个。我怎样才能做到这一点?

【问题讨论】:

    标签: javascript typescript selenium appium webdriver-io


    【解决方案1】:

    为两个配置文件创建单独的测试命令。然后在 package.json 中添加一个新脚本,其中两个测试命令用 && 分隔。

    https://stackoverflow.com/a/53809731/8903949

    (或)

    使用 gulp 或 grunt 任务。

    【讨论】:

    • 但是在我的情况下我将如何添加?完成第一个后它还会运行吗?
    • 这肯定会一个接一个地执行。两者都是不同的 npm 脚本。
    • 脚本 test1 将具有“wdio config1.js”,而 test2 将具有“wdio config2.js”
    • 但是什么是 test1 和 test2 我有点困惑
    • 您应该运行npm run test,它首先运行浏览器测试,然后运行移动测试。
    【解决方案2】:

    我遇到了同样的情况。我在这个案例中使用了一个 shell 脚本文件。

    对于 MAC 和 Linux:创建 run.sh 文件,然后使用命令 sh run.sh

    #!/bin/bash
    npm run android.sauce.rdc.app
    npm run consumer.app
    npm run ...
    

    对于 Windows:创建 run.bat 文件,然后运行它。

    npm run android.sauce.rdc.app
    npm run consumer.app
    npm run ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多