-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtest.js
34 lines (27 loc) · 912 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const spawn = require('child_process').spawn;
const webdriver = require('selenium-webdriver');
// Input capabilities
const capabilities = {
'browserName' : 'safari',
'version': '9.1',
'browserstack.user' : 'derekgray2',
'browserstack.key' : 'aSyZj64XMxH3Eb61nCf4',
'browserstack.local': true
};
const serverCmd = process.platform === 'win32' ? 'http-server.cmd' : 'http-server';
const server = spawn(serverCmd, ['-p', '50573']);
const driver = new webdriver.Builder()
.usingServer('http://hub-cloud.browserstack.com/wd/hub')
.withCapabilities(capabilities)
.build();
driver.get('http://localhost:50573/tests/index.html');
driver.executeScript('return window.failedTests;').then(failures => {
if (!failures.length) {
console.log('All tests passed');
return;
}
console.log('One or more tests failed');
console.log(failures);
});
driver.quit();
server.kill();