问题
I currently have two wdio.config.js files with different configurations. How can i run both one after another? Is it possible?
This is how I am defining in the code:
first 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
}, */
//
//
}
second 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
}, */
//
//
}
and my package.json file:
{
"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"
}
}
I would like to run the first one then the second one with one command. How can i achieve that?
回答1:
Create individual test command for both config files. Then add a new script in package.json having both the test commands separated by &&.
https://stackoverflow.com/a/53809731/8903949
(Or)
Use gulp or grunt task.
回答2:
I faced the same case. I used a shell script file for this case.
For MAC and Linux: create run.sh
file, then use command sh run.sh
#!/bin/bash
npm run android.sauce.rdc.app
npm run consumer.app
npm run ...
For Windows: create run.bat
file, then run it.
npm run android.sauce.rdc.app
npm run consumer.app
npm run ...
来源:https://stackoverflow.com/questions/59650841/how-to-run-two-different-wdio-config-js-file-one-after-another