commit | author | age
|
f17951
|
1 |
const seleniumServer = require("selenium-server"); |
D |
2 |
const chromedriver = require("chromedriver"); |
|
3 |
const SCREENSHOT_PATH = "./reports/screenshots/"; |
|
4 |
|
|
5 |
module.exports = { |
93d04e
|
6 |
src_folders: [ |
D |
7 |
"tests/e2e/specs" // Where you are storing your Nightwatch e2e tests |
f17951
|
8 |
], |
d3c92c
|
9 |
// TODO - move to the package.json |
93d04e
|
10 |
// urlToTest: process.env.E2E_ENV ? `http://app-name-labs-${process.env.E2E_ENV}.apps.company-xyz.rht-labs.com`: "http://localhost:8080", |
D |
11 |
output_folder: "./reports/e2e", |
|
12 |
selenium: { |
|
13 |
start_process: true, // tells nightwatch to start/stop the selenium process |
|
14 |
server_path: seleniumServer.path, |
|
15 |
host: "127.0.0.1", |
|
16 |
port: 4444, |
|
17 |
cli_args: { |
|
18 |
"webdriver.chrome.driver": chromedriver.path |
f17951
|
19 |
} |
D |
20 |
}, |
93d04e
|
21 |
test_settings: { |
D |
22 |
jenkins: { |
|
23 |
end_session_on_fail: false, |
|
24 |
screenshots: { |
|
25 |
enabled: true, |
|
26 |
on_failure: true, |
|
27 |
path: "./reports/e2e" |
f17951
|
28 |
}, |
93d04e
|
29 |
desiredCapabilities: { |
D |
30 |
browserName: "chrome", |
|
31 |
javascriptEnabled: true, |
|
32 |
acceptSslCerts: true, |
|
33 |
chromeOptions: { |
|
34 |
args: [ |
|
35 |
"disable-web-security", |
|
36 |
"ignore-certificate-errors", |
|
37 |
"headless", |
|
38 |
"no-sandbox" |
|
39 |
] |
f17951
|
40 |
} |
D |
41 |
} |
|
42 |
} |
|
43 |
} |
d3c92c
|
44 |
}; |
f17951
|
45 |
|
d3c92c
|
46 |
function padLeft(count) { |
D |
47 |
// theregister.co.uk/2016/03/23/npm_left_pad_chaos/ |
|
48 |
return count < 10 ? "0" + count : count.toString(); |
f17951
|
49 |
} |
D |
50 |
|
93d04e
|
51 |
var FILECOUNT = 0; // global screenshot file count |
f17951
|
52 |
/** |
D |
53 |
* The default is to save screenshots to the root of your project even though |
93d04e
|
54 |
* there is a screenshots path in the config object axwxxwbove! ... so we need a |
f17951
|
55 |
* function that returns the correct path for storing our screenshots. |
93d04e
|
56 |
* While we"re at it, we are adding some meta-data to the filename, specifically |
f17951
|
57 |
* the Platform/Browser where the test was run and the test (file) name. |
D |
58 |
*/ |
d3c92c
|
59 |
function imgpath(browser) { |
f17951
|
60 |
var a = browser.options.desiredCapabilities; |
D |
61 |
var meta = [a.platform]; |
d3c92c
|
62 |
meta.push(a.browserName ? a.browserName : "any"); |
D |
63 |
meta.push(a.version ? a.version : "any"); |
f17951
|
64 |
meta.push(a.name); // this is the test filename so always exists. |
d3c92c
|
65 |
var metadata = meta |
D |
66 |
.join("~") |
|
67 |
.toLowerCase() |
|
68 |
.replace(/ /g, ""); |
93d04e
|
69 |
return SCREENSHOT_PATH + metadata + "_" + padLeft(FILECOUNT++) + "_"; |
f17951
|
70 |
} |
D |
71 |
|
|
72 |
module.exports.imgpath = imgpath; |
d3c92c
|
73 |
module.exports.SCREENSHOT_PATH = SCREENSHOT_PATH; |