Я хочу запустить проверку автоматизации Nightwatch вaucelab для локальных URL-адресов, но не хочу запускать sauceconnect в отдельном терминале.
Я попробовал это, и вот мои файлы nighwatch.json и nightwatch.config.js код:
Код файла nightwatch.json:
{
"src_folders" : ["tests"],
"output_folder" : "reports",
"custom_commands_path" : "custom_commands",
"custom_assertions_path" : "",
"page_objects_path" : "",
"globals_path" : "",
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_port" : 80,
"selenium_host" : "ondemand.saucelabs.com",
"silent": true,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"username" : "${SAUCE_USERNAME}",
"access_key" : "${SAUCE_ACCESS_KEY}",
"skip_testcases_on_fail": false,
"desiredCapabilities": {
"javascriptEnabled": true,
"acceptSslCerts": true
}
},
"chrome": {
"desiredCapabilities": {
"platform": "Windows 7",
"browserName": "chrome",
"version": "latest"
}
},
"firefox" : {
"desiredCapabilities": {
"platform": "Windows 8",
"browserName": "firefox",
"version": "33"
}
},
"internet_explorer_edge" : {
"desiredCapabilities": {
"platform": "Windows 10",
"browserName": "MicrosoftEdge",
"version": "latest"
}
},
"android_s4_emulator": {
"desiredCapabilities": {
"browserName": "android",
"deviceOrientation": "portrait",
"deviceName": "Samsung Galaxy S4 Emulator"
}
},
"iphone_6_simulator": {
"desiredCapabilities": {
"browserName": "iPhone",
"deviceOrientation": "portrait",
"deviceName": "iPhone 6",
"platform": "OSX 10.10",
"version": "8.4"
}
}
}
}
Вот моя ночная часы.config.js код файла:
const sauceConnectLauncher = require('sauce-connect-launcher');
module.exports = (function (settings) {
let sauce;
let launcher;
const closeSauce = () => new Promise((resolve, reject) => {
try {
sauce.close(resolve);
} catch (e) {
console.log(e)
}
});
const openSauce = () => {
if (!launcher) {
launcher = new Promise((resolve, reject) => {
sauceConnectLauncher({
"username" : "${SAUCE_USERNAME}",
"access_key" : "${SAUCE_ACCESS_KEY}",
}, ((err, process) => {
console.log("Started Sauce Connect Process");
sauce = process;
err && reject(err);
!err && resolve(process);
}));
});
}
return launcher.then(() => {
return cb();
});
};
const catchError = (e) => console.log(`e`, e);
settings.test_settings.default.globals = {
before: (done) => {
Promise.resolve()
.then(() => (
openSauce()
))
.then(done)
.catch(catchError);
},
after: function (done) {
Promise.resolve()
.then(() => (
closeSauce()
))
.then(done)
.then(() => process.exit(0))
.catch(catchError);
}
};
return settings;
})(require('./nightwatch.json'));
Но я получил ошибку ниже:
Started Sauce Connect Process
e Error: Could not start Sauce Connect. Exit code 1 signal: null
at ChildProcess.<anonymous> (C:\Mint\Repositories\nightwatch1.0.18-saucelabTesting\node_modules\sauce-connect-launcher\lib\sauce-connect-launcher.js:559:12)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
done() callback timeout of 10000ms was reached while executing "before". Make sure to call the done() callback when the operation finishes.
TypeError: Cannot read property 'close' of undefined
at Promise (C:\Mint\Repositories\nightwatch1.0.18-saucelabTesting\nightwatch.conf.js:10:13)
at new Promise (<anonymous>)
at closeSauce (C:\Mint\Repositories\nightwatch1.0.18-saucelabTesting\nightwatch.conf.js:8:28)
at Promise.resolve.then (C:\Mint\Repositories\nightwatch1.0.18-saucelabTesting\nightwatch.conf.js:50:11)
at <anonymous>
done() callback timeout of 10000ms was reached while executing "after". Make sure to call the done() callback when the operation finishes.
Я попробовал это в первый раз, и я не знаю точный процесс, может кто-нибудь одинукажи мне точный процесс.