Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.

Commit 26d385e

Browse files
committed
add basic liveTestResults example
1 parent df891dc commit 26d385e

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

examples/liveTestResults.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
var cbt = require('cbt_tunnels');
2+
var request = require('request');
3+
4+
var authkey = ""; // Place CBT user credentials here
5+
var username = "";
6+
7+
var configObj = {
8+
authkey: authkey,
9+
username: username,
10+
}
11+
12+
var baseUrl = 'https://' + configObj.username + ':' + configObj.authkey + '@crossbrowsertesting.com/api/v3/';
13+
console.info("baseUrl: ", baseUrl);
14+
15+
// https://crossbrowsertesting.com/apidocs/v3/livetests.html#!/default/get_livetests
16+
17+
cbt.start(configObj, function(err) {
18+
if (err) {
19+
console.error("Error starting: ", err);
20+
return err;
21+
}
22+
var queryUrl = baseUrl + 'livetests?format=json&num=10&active=true&os_type=mac&browser_type=firefox';
23+
request.get({ url: queryUrl }, function(error, response, body) {
24+
if (error) {
25+
console.error("Error posting: ", error);
26+
return error;
27+
}
28+
29+
var livetests = JSON.parse(body).livetests;
30+
console.log("livetest count: ", livetests.length);
31+
32+
for (var test of livetests) {
33+
// do something
34+
}
35+
36+
cbt.stop();
37+
console.log('Exiting!');
38+
process.exit(0);
39+
});
40+
});

0 commit comments

Comments
 (0)