-
Notifications
You must be signed in to change notification settings - Fork 0
/
protractor.conf.js
161 lines (136 loc) · 4.66 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
require('./log4js-config').init();
const log = require('log4js').getLogger('conf-logger');
const fs = require('fs');
const path = require('path');
const { SpecReporter } = require('jasmine-spec-reporter');
const AllureReporter = require('jasmine-allure-reporter');
function setupCapabilities(config) {
let capabilityName = process.env.CAPABILITY_NAME;
// let { capabilityName } = browser.params; // --params can be used also
const supportedCapabilities = ['chrome', 'firefox', 'multiple', 'headless-chrome'];
log.debug(`capability name in setup: <${capabilityName}>`);
if (capabilityName === undefined || capabilityName === '') {
log.warn('using default chrome setup');
capabilityName = 'chrome';
}
if (!supportedCapabilities.includes(capabilityName)) {
throw new Error(`unknown capability, should be one of: ${supportedCapabilities}`);
}
log.info(`prepare capabilities for: ${capabilityName}`);
// https://www.protractortest.org/#/browser-setup
// https://sites.google.com/a/chromium.org/chromedriver/capabilities
const capabilitiesMap = {
chrome: {
browserName: 'chrome',
enableVNC: true,
version: '',
platform: 'ANY',
chromeOptions: {
args: ['--lang=en'],
},
},
// https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities/firefoxOptions#Prefs
firefox: {
browserName: 'firefox',
enableVNC: true,
'moz:firefoxOptions': {
prefs: {
'geo.enabled': false,
},
},
},
multiple: [
{
browserName: 'chrome',
},
{
browserName: 'firefox',
},
],
'headless-chrome': {
browserName: 'chrome',
chromeOptions: {
args: ['--headless', '--disable-gpu', '--window-size=1600,1200'],
},
},
};
/* eslint-disable no-param-reassign */
if (capabilityName === 'multiple') {
config.multiCapabilities = capabilitiesMap[capabilityName];
} else {
config.capabilities = capabilitiesMap[capabilityName];
}
/* eslint-enable no-param-reassign */
}
const config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
ignoreUncaughtExceptions: true,
specs: [
'specs/takeaway.orders.spec.js',
'specs/booking.search.spec.js',
'specs/google.search.spec.js',
'specs/itera.vacancies.spec.js',
],
SELENIUM_PROMISE_MANAGER: false,
framework: 'jasmine2',
allScriptsTimeout: 300000,
getPageTimeout: 120000,
// uncomment for debug
// useBlockingProxy: true,
// highlightDelay: 3000,
// webDriverLogDir: 'logs',
// seleniumSessionId: '091cda6b89457082ee779ccc358f473c',
onPrepare() {
const width = 1600;
const height = 900;
browser.driver.manage().window().setSize(width, height);
// reporters
jasmine.getEnv().addReporter(
new SpecReporter({
suite: {
displayNumber: true,
},
spec: {
displayStackTrace: true,
displayDuration: true,
},
summary: {
displayDuration: true,
},
}),
);
jasmine.getEnv().addReporter(new AllureReporter({
resultsDir: 'allure-results',
}));
jasmine.getEnv().afterEach(async () => {
const png = await browser.takeScreenshot();
const pngBuffer = Buffer.from(png, 'base64');
allure.createAttachment('Screenshot', pngBuffer, 'image/png');
});
// temporary solution for unhandled rejections
process.on('unhandledRejection', (error) => {
log.warn('unhandledRejection');
log.warn(error);
});
},
onComplete() {
const browserLogsFilePath = path.join(__dirname, 'browser.log');
browser.manage().logs().get('browser')
.then(browserLogs => {
browserLogs.forEach(logMsg => {
const timestamp = new Date(0);
timestamp.setUTCSeconds(logMsg.timestamp);
fs.appendFileSync(browserLogsFilePath, `[${timestamp}] ${logMsg.message} \n`);
});
});
},
jasmineNodeOpts: {
isVerbose: true,
showColors: true,
includeStackTrace: true,
print() {}, // turn off dots
},
};
setupCapabilities(config);
log.info(config);
exports.config = config;