1 | const SCREENSHOT_PATH = "./screenshots/"; |
||
2 | const BINPATH = './node_modules/nightwatch/bin/'; |
||
3 | |||
4 | module.exports = { |
||
5 | "src_folders": [ |
||
6 | "tests/e2e" |
||
7 | ], |
||
8 | "output_folder": "./reports", |
||
9 | "test_runner" : "mocha", |
||
10 | "selenium": { |
||
11 | "start_process": true, |
||
12 | "server_path": "./node_modules/nightwatch/bin/selenium.jar", |
||
13 | "host": "127.0.0.1", |
||
14 | "port": 4444, |
||
15 | "cli_args": { |
||
16 | "webdriver.chrome.driver" : "./node_modules/nightwatch/bin/chromedriver" |
||
17 | } |
||
18 | }, |
||
19 | "test_settings": { |
||
20 | "default": { |
||
21 | "launch_url" : "http://localhost:3003/abe/editor", |
||
22 | "silent": true, |
||
23 | "screenshots": { |
||
24 | "enabled": false, |
||
25 | "path": '' |
||
26 | }, |
||
27 | "globals": { |
||
28 | "waitForConditionTimeout": 3000 |
||
29 | }, |
||
30 | "desiredCapabilities" : { |
||
31 | "browserName" : "chrome", |
||
32 | "javascriptEnabled" : true, |
||
33 | "acceptSslCerts" : true, |
||
34 | "chromeOptions" : { |
||
35 | "args" : ["start-fullscreen"] |
||
36 | } |
||
37 | } |
||
38 | }, |
||
39 | "chrome": { |
||
40 | "desiredCapabilities": { |
||
41 | "browserName": "chrome", |
||
42 | "javascriptEnabled": true, |
||
43 | "acceptSslCerts" : true, |
||
44 | "chromeOptions" : { |
||
45 | "args" : ["start-fullscreen"] |
||
46 | } |
||
47 | } |
||
48 | } |
||
49 | } |
||
50 | } |
||
51 | /** |
||
52 | * selenium-download does exactly what it's name suggests; |
||
53 | * downloads (or updates) the version of Selenium (& chromedriver) |
||
54 | * on your localhost where it will be used by Nightwatch. |
||
55 | /the following code checks for the existence of `selenium.jar` before trying to run our tests. |
||
56 | */ |
||
57 | |||
58 | require('fs').stat(BINPATH + 'selenium.jar', function (err, stat) { // got it? |
||
59 | if (err || !stat || stat.size < 1) { |
||
60 | require('selenium-download').ensure(BINPATH, function(error) { |
||
61 | if (error) throw new Error(error); // no point continuing so exit! |
||
62 | console.log('✔ Selenium & Chromedriver downloaded to:', BINPATH); |
||
0 ignored issues
–
show
Debugging Code
introduced
by
![]() |
|||
63 | }); |
||
64 | } |
||
65 | }); |
||
66 | |||
67 | function padLeft (count) { |
||
68 | return count < 10 ? '0' + count : count.toString(); |
||
69 | } |
||
70 | |||
71 | var FILECOUNT = 0; |
||
72 | /** |
||
73 | * The default is to save screenshots to the root of your project even though |
||
74 | * there is a screenshots path in the config object above! ... so we need a |
||
75 | * function that returns the correct path for storing our screenshots. |
||
76 | * While we're at it, we are adding some meta-data to the filename, specifically |
||
77 | * the Platform/Browser where the test was run and the test (file) name. |
||
78 | */ |
||
79 | function imgpath (browser) { |
||
80 | var a = browser.options.desiredCapabilities; |
||
81 | var meta = [a.platform]; |
||
82 | meta.push(a.browserName ? a.browserName : 'any'); |
||
83 | meta.push(a.version ? a.version : 'any'); |
||
84 | meta.push(a.name); // this is the test filename so always exists. |
||
85 | var metadata = meta.join('~').toLowerCase().replace(/ /g, ''); |
||
86 | return SCREENSHOT_PATH + metadata + '_' + padLeft(FILECOUNT++) + '_'; |
||
87 | } |
||
88 | |||
89 | module.exports.imgpath = imgpath; |
||
90 | module.exports.SCREENSHOT_PATH = SCREENSHOT_PATH; |