-
Notifications
You must be signed in to change notification settings - Fork 5
/
common.js
51 lines (39 loc) · 1.35 KB
/
common.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
var http = require('http');
var Common = function () {
this.goHome = function () {
browser.get(browser.params.client)
};
this.logoutButton = element(by.buttonText('Logout'));
this.overviewMenuButton = element(by.buttonText('Overview'));
this.outcomesMenuButton = element(by.buttonText('Outcomes'));
this.reflectionsMenuButton = element(by.buttonText('Reflections'));
this.hotSpotsMenuButton = element(by.buttonText('Hot Spots'));
this.clearDB = function () {
var deferred = protractor.promise.defer();
var options = {
hostname: 'localhost',
port: 4321,
path: '/api/forTest',
method: 'DELETE'
};
callback = function() {
deferred.fulfill();
};
var req = http.request(options, callback);
req.on('error', function (e) {
console.log("Error occurred with clear DB API Call: " + e.message);
});
req.end();
return deferred.promise;
};
this.generateRandomUsername = function () {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
};
};
module.exports = Common;