-
Notifications
You must be signed in to change notification settings - Fork 10
/
protractor.ci.conf.js
126 lines (114 loc) · 3.64 KB
/
protractor.ci.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
let csv = require("fast-csv");
let _ = require("lodash");
let fs = require('fs');
const globals = require('protractor');
let getMultipleBrowserCapability = function (params) {
let returnArray = new Array();
console.log(params.browsers)
var browsers = params.browsers.split(',');
browsers.forEach(function (element) {
returnArray.push({
'browserName': element
})
}, this);
console.log(returnArray);
return returnArray;
};
exports.config = {
allScriptsTimeout: 180000,
specs: ['features/**/*.feature'],
exclude: ['features/no_edit.feature'],
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
binary: '/usr/bin/google-chrome',
args: ['--headless', '--enable-logging','--v=1'],
extensions: []
}
},
// multiCapabilities:
// [
// {
// browserName: 'chrome',
// // chromeOptions: {
// // args: [ "--headless", "--disable-gpu", "--window-size=800,600" ]
// // }
// },
// // {
// // 'browserName': 'firefox'
// // }
// ],
plugins: [],
directConnect: true,
//seleniumAddress: 'http://localhost:4444/wd/hub',
framework: 'custom',
ignoreUncaughtExceptions: true,
frameworkPath: require.resolve('protractor-cucumber-framework'),
cucumberOpts: {
compiler: "ts:ts-node/register",
format: "json:reports/cucumberReport.json",
require: [
'lib/**/*.ts',
'features/step_definitions/**/*.steps.ts'
]
},
useAllAngular2AppRoots: true,
onPrepare: function () {
const browser = globals.browser;
browser.ignoreSynchronization = true;
var { defineSupportCode } = require('cucumber');
var reporter = require('cucumber-html-reporter');
defineSupportCode(function ({ After }) {
After(function (scenarioResult) {
var world = this;
if (scenarioResult.isFailed()) {
return browser.takeScreenshot().then(function (png) {
// screenShot is a base-64 encoded PNG
var decodedImage = new Buffer(png.replace(/^data:image\/(png|gif|jpeg);base64,/, ''), 'base64');
world.attach(decodedImage, 'image/png');
});
}
});
});
var options = {
theme: 'bootstrap',
jsonFile: 'reports/cucumberReport.json',
output: 'results/reports/testResults.html',
reportSuiteAsScenarios: true,
launchReport: true,
};
defineSupportCode(function ({ registerHandler }) {
registerHandler('AfterFeatures', function (features) {
reporter.generate(options);
});
});
let repoElementsArray = new Array();
let files = fs.readdirSync('./repository');
if (files.length == 0) throw new Error('No Object Repository files found. There should be at least one object repository file.');
let promiseArray = [];
files.forEach((file) => {
console.log('Now reading repository file "' + file + '"');
let tempPromise = new Promise((resolve, reject) => {
try {
csv.fromPath('./repository/' + file, { headers: true, ignoreEmpty: true, trim: true })
.on("data", function (data) {
if (!_.find(repoElementsArray, (object) => { return data.elementKey === object.elementKey })) {
repoElementsArray.push(data);
} else {
console.log('Duplicate object found and ignored ', data);
}
})
.on("end", function () {
browser.params.OBJECT_REPO = repoElementsArray;
resolve();
});
}
catch (error) {
reject(error.message);
}
});
promiseArray.push(tempPromise);
});
return Promise.all(promiseArray);
}
};