Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.onBrowserComplete = function(browser) {
const result = browser.lastResult;
const browserId = browser.id;
if (result.disconnected) {
log.error('✖ Browser disconnected');
}
if (result.error) {
log.error('✖ Tests errored');
}
const browserData = browserMap.get(browserId);
// Do nothing if the current browser has not been launched through the Saucelabs launcher
if (!browserData) {
return;
}
const { username, accessKey, proxy, sessionId } = browserData;
const saucelabs = new SauceLabs({
user: username,
key: accessKey,
proxy,
});
const hasPassed = !(result.failed || result.error || result.disconnected);
// Update the job by reporting the test results. Also we need to store the promise here
// because in case "onExit" is being called, we want to wait for the API calls to finish.
pendingUpdates.push(
saucelabs.updateJob(username, sessionId, {
'passed': hasPassed,
'custom-data': result,
}).catch(error => log.error('Could not report results to Saucelabs: %s', error))
);
};
// Whenever this method is being called, we just need to wait for all API calls to finish,
return new Promise(function(resolve, reject) {
console.log("");
console.log(caps.name);
const username = caps.username;
const accessKey = caps.accessKey;
const saucelabs = new SauceLabs({
username: username,
password: accessKey
});
const By = webdriver.By;
let driver = new webdriver.Builder()
.withCapabilities(caps)
.usingServer(
"http://" + username + ":" + accessKey + "@localhost:4445/wd/hub"
)
.build();
driver.get(
"http://localhost:5000/test/index.html"
);