如何在sauceLabs上运行多个具有不同功能的远程设备,但是在一次运行测试中,启动了两个设备(移动设备和浏览器),我将它们的功能放在webClient和客户端变量中,例如,我需要并行运行三个运行它们中的每一个都运行两个设备是浏览器和手机,其功能在两个webClient和client变量中涵盖。
发生的第一件事是一系列功能,可以在ucelabs上运行所有设备,但是当测试开始时,变量client和webClient未定义。
exports.config = {
suites: {
specs: [
'./dist/e2e/Specs/1_sauceLabs_test.js'
]
},
capabilities:
[
{
browserName: 'chrome',
platformName: 'OS X',
pageLoadStrategy: 'normal'
},
{
appiumVersion: '1.13.0',
platformVersion: "8.1",
deviceName: "Samsung Galaxy S9 Plus WQHD GoogleAPI Emulator",
browserName: "",
platformName: "Android",
app: 'http://appium.s3.amazonaws.com/ContactManager.apk',
deviceOrientation: 'portrait'
},
{
appiumVersion: '1.13.0',
platformVersion: "8.1",
deviceName: "Samsung Galaxy S9 Plus WQHD GoogleAPI Emulator",
browserName: "",
platformName: "Android",
app: 'http://appium.s3.amazonaws.com/ContactManager.apk',
deviceOrientation: 'portrait'
}
],
maxInstances: 4,
deprecationWarnings: false,
sync: true,
logLevel: 'error',
coloredLogs: true,
bail: 0,
screenshotPath: './errorShots/',
baseUrl: 'https://google.com',
waitforTimeout: 20000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
user: '**************',
key: '*********************************',
sauceConnectOpts: {
logger: function (message) {
console.log(`[SauceLabs]: ${message}`);
}
},
services: ['sauce'],
sauceConnect: true,
framework: 'jasmine',
jasmineNodeOpts: {
random: false,
showColors: true,
includeStackTrace: true,
defaultTimeoutInterval: 12 * 60 * 1000,
},
onPrepare: (config, capabilities) => {
},
beforeSession: (config, capabilities, specs) => {
require('babel-register');
},
before: (capabilities, specs) => {
let SpecReporter = require('jasmine-spec-reporter/built/main').SpecReporter;
jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: true, displayErrorMessages: true}));
isTablet = client.desiredCapabilities.isTablet;
}
};
使用这样的数组,我只能在一次运行中使用两个设备而不是多个设备来获取变量
capabilities: {
webClient: {
desiredCapabilities: {
browserName: 'chrome',
platformName: 'OS X',
pageLoadStrategy: 'normal'
}
},
client: {
desiredCapabilities: {
appiumVersion: '1.13.0',
platformVersion: "8.1",
deviceName: "Samsung Galaxy S9 Plus WQHD GoogleAPI Emulator",
browserName: "",
platformName: "Android",
app: 'http://appium.s3.amazonaws.com/ContactManager.apk',
deviceOrientation: 'portrait'
}
}
}
我再次尝试了吗?但出现相同的错误“ ReferenceError:未定义客户端”
capabilities: [{
webClient: {
desiredCapabilities: {
browserName: 'chrome',
platformName: 'OS X',
pageLoadStrategy: 'normal'
}
},
client: {
desiredCapabilities: {
appiumVersion: '1.13.0',
platformVersion: "8.1",
deviceName: "Samsung Galaxy S9 Plus WQHD GoogleAPI Emulator",
browserName: "",
platformName: "Android",
app: 'http://appium.s3.amazonaws.com/ContactManager.apk',
deviceOrientation: 'portrait'
}
}
}, {
webClient: {
desiredCapabilities: {
browserName: 'chrome',
platformName: 'OS X',
pageLoadStrategy: 'normal'
}
},
client: {
desiredCapabilities: {
appiumVersion: '1.13.0',
platformVersion: "8.1",
deviceName: "Samsung Galaxy S9 Plus WQHD GoogleAPI Emulator",
browserName: "",
platformName: "Android",
app: 'http://appium.s3.amazonaws.com/ContactManager.apk',
deviceOrientation: 'portrait'
}
}
}]