-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprotractor.conf.js
93 lines (74 loc) · 2.08 KB
/
protractor.conf.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*global exports,browser */
'use strict';
require('babel-register');
require('babel-polyfill');
var Cookie = require('tough-cookie');
var request = require('request-promise');
var fs = require('fs');
var path = require('path');
function login(steamid) {
steamid = steamid || 76561197970669109;
var url = browser.params.apiUrl + '/startMockLogin?steamid=' + steamid;
return request.get(url, {
resolveWithFullResponse: true,
followRedirect: false,
simple: false
}).then(function (res) {
var authCookie = Cookie.parse(res.headers['set-cookie'][0]);
browser.driver.get(browser.params.apiUrl);
browser.manage().addCookie(authCookie.key, authCookie.value, authCookie.path, authCookie.domain);
});
}
function dirExists(dirName) {
try {
var stat = fs.statSync(dirName);
return stat.isDirectory();
}
catch (e) {
return false;
}
}
function writeScreenShot(data, filename) {
var stream = fs.createWriteStream(filename);
stream.write(new Buffer(data, 'base64'));
stream.end();
}
function saveScreenshot(filename) {
browser.takeScreenshot().then(function (png) {
writeScreenShot(png, filename);
});
}
exports.config = {
framework: 'jasmine',
baseUrl: 'http://localhost:8080/',
// disable, see if it works again with next protractor version
// directConnect: true,
specs: ['tests/**.js'],
capabilities: {
browserName: 'firefox'
},
params: {
viewport: {
width: 1200,
height: 900
},
screenshots: 'screenshots'
},
onPrepare: function () {
if (browser.params.screenshots && browser.params.screenshots !== 'false') {
var screenshotsDir = browser.params.screenshots;
if (!dirExists(screenshotsDir)) {
fs.mkdirSync(screenshotsDir);
}
global.takeScreenshot = function (name) {
saveScreenshot(path.join(screenshotsDir, name + '.png'));
};
} else {
global.takeScreenshot = function () {};
}
global.login = login;
var win = browser.manage().window();
var viewport = browser.params.viewport;
win.setSize(viewport.width, viewport.height);
}
};