webship-js 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +15 -8
- package/.github/workflows/github-actions.yml +13 -10
- package/.gitlab-ci.yml +1 -0
- package/.travis-ci.yml +0 -0
- package/README.md +1 -1
- package/assets/config_templates/circleci-linux-chrome.conf.js +100 -0
- package/assets/config_templates/github-linux-chrome.conf.js +111 -0
- package/{bitbucket-pipelines.yml → bitbucket-pipelines-test.yml} +0 -0
- package/examples/about-us.html +10 -0
- package/examples/contact-us.html +10 -0
- package/examples/index.html +26 -0
- package/examples/main.js +17 -0
- package/examples/test--when--i-fill-in.html +48 -0
- package/examples/test--when--i-follow-link.html +18 -0
- package/examples/test--when--i-press-button.html +27 -0
- package/examples/test--when--i-reload-page.html +27 -0
- package/examples/test--when--i-select-option-from-selectbox.html +35 -0
- package/lib/custom-commands/smartSelectOption.js +15 -0
- package/lib/get-element.js +65 -0
- package/nightwatch.conf.js +24 -259
- package/package.json +11 -4
- package/src/index.js +10 -0
- package/steplist.js +101 -64
- package/tests/features/test--given--i-am-on-homepage.feature +12 -0
- package/tests/features/test--when--i-fill-in.feature +36 -0
- package/tests/features/test--when--i-follow-link.feature +11 -0
- package/tests/features/test--when--i-move-forward-backward-one-page.feature +14 -0
- package/tests/features/test--when--i-press-button.feature +11 -0
- package/tests/features/test--when--i-reload-page.feature +14 -0
- package/tests/features/test--when--i-select-option-from-selectbox.feature +13 -0
- package/tests/reports/cucumber-report.html +0 -0
- package/tests/reports/cucumber-report.json +0 -0
- package/tests/step-definitions/webship.js +156 -10
- package/webpack.config.js +17 -0
- package/webship-init.js +75 -0
- package/tests/features/check-webshipco-site.feature +0 -8
package/nightwatch.conf.js
CHANGED
|
@@ -1,32 +1,12 @@
|
|
|
1
1
|
const Services = {}; loadServices();
|
|
2
2
|
|
|
3
|
-
// _ _ _ _ _ _ _
|
|
4
|
-
// | \ | |(_) | | | | | | | |
|
|
5
|
-
// | \| | _ __ _ | |__ | |_ __ __ __ _ | |_ ___ | |__
|
|
6
|
-
// | . ` || | / _` || '_ \ | __|\ \ /\ / / / _` || __| / __|| '_ \
|
|
7
|
-
// | |\ || || (_| || | | || |_ \ V V / | (_| || |_ | (__ | | | |
|
|
8
|
-
// \_| \_/|_| \__, ||_| |_| \__| \_/\_/ \__,_| \__| \___||_| |_|
|
|
9
|
-
// __/ |
|
|
10
|
-
// |___/
|
|
11
|
-
|
|
12
3
|
module.exports = {
|
|
13
4
|
// An array of folders (excluding subfolders) where your tests are located;
|
|
14
5
|
// if this is not specified, the test source must be passed as the second argument to the test runner.
|
|
15
6
|
src_folders: ['tests/step-definitions'],
|
|
16
7
|
|
|
17
|
-
// See https://nightwatchjs.org/guide/working-with-page-objects/
|
|
18
|
-
page_objects_path: '',
|
|
19
|
-
|
|
20
8
|
// See https://nightwatchjs.org/guide/extending-nightwatch/#writing-custom-commands
|
|
21
|
-
custom_commands_path: '',
|
|
22
|
-
|
|
23
|
-
// See https://nightwatchjs.org/guide/extending-nightwatch/#writing-custom-assertions
|
|
24
|
-
custom_assertions_path: '',
|
|
25
|
-
|
|
26
|
-
// See https://nightwatchjs.org/guide/#external-globals
|
|
27
|
-
globals_path: '',
|
|
28
|
-
|
|
29
|
-
webdriver: {},
|
|
9
|
+
custom_commands_path: './lib/custom-commands',
|
|
30
10
|
|
|
31
11
|
test_runner: {
|
|
32
12
|
type: 'cucumber',
|
|
@@ -35,12 +15,11 @@ module.exports = {
|
|
|
35
15
|
additional_config: '',
|
|
36
16
|
parallel: 2,
|
|
37
17
|
},
|
|
38
|
-
|
|
39
18
|
},
|
|
40
19
|
|
|
41
20
|
test_settings: {
|
|
42
21
|
default: {
|
|
43
|
-
launch_url: '
|
|
22
|
+
launch_url: 'http://localhost:8080/',
|
|
44
23
|
selenium_port: 4444,
|
|
45
24
|
selenium_host: '127.0.0.1',
|
|
46
25
|
silent: true,
|
|
@@ -80,256 +59,42 @@ module.exports = {
|
|
|
80
59
|
},
|
|
81
60
|
},
|
|
82
61
|
},
|
|
62
|
+
},
|
|
83
63
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
server_path: '',
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
firefox: {
|
|
98
|
-
desiredCapabilities: {
|
|
99
|
-
browserName: 'firefox',
|
|
100
|
-
alwaysMatch: {
|
|
101
|
-
acceptInsecureCerts: true,
|
|
102
|
-
'moz:firefoxOptions': {
|
|
103
|
-
args: [
|
|
104
|
-
// '-headless',
|
|
105
|
-
// '-verbose'
|
|
106
|
-
],
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
webdriver: {
|
|
111
|
-
start_process: true,
|
|
112
|
-
server_path: '',
|
|
113
|
-
cli_args: [
|
|
114
|
-
// very verbose geckodriver logs
|
|
115
|
-
// '-vv'
|
|
116
|
-
],
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
chrome: {
|
|
121
|
-
desiredCapabilities: {
|
|
122
|
-
browserName: 'chrome',
|
|
123
|
-
'goog:chromeOptions': {
|
|
124
|
-
// More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
|
|
125
|
-
//
|
|
126
|
-
// w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
|
|
127
|
-
w3c: true,
|
|
128
|
-
args: [
|
|
129
|
-
// '--no-sandbox',
|
|
130
|
-
// '--ignore-certificate-errors',
|
|
131
|
-
// '--allow-insecure-localhost',
|
|
132
|
-
// '--headless'
|
|
133
|
-
],
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
webdriver: {
|
|
138
|
-
start_process: true,
|
|
139
|
-
server_path: '',
|
|
140
|
-
cli_args: [
|
|
141
|
-
// --verbose
|
|
142
|
-
],
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
edge: {
|
|
147
|
-
desiredCapabilities: {
|
|
148
|
-
browserName: 'MicrosoftEdge',
|
|
149
|
-
'ms:edgeOptions': {
|
|
150
|
-
w3c: true,
|
|
151
|
-
// More info on EdgeDriver: https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/capabilities-edge-options
|
|
152
|
-
args: [
|
|
153
|
-
// '--headless'
|
|
154
|
-
],
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
|
|
158
|
-
webdriver: {
|
|
159
|
-
start_process: true,
|
|
160
|
-
// Download msedgedriver from https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/
|
|
161
|
-
// and set the location below:
|
|
162
|
-
server_path: '',
|
|
163
|
-
cli_args: [
|
|
164
|
-
// --verbose
|
|
165
|
-
],
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
/// ///////////////////////////////////////////////////////////////////////////////
|
|
170
|
-
// Configuration for when using cucumber-js (https://cucumber.io) |
|
|
171
|
-
// |
|
|
172
|
-
// It uses the bundled examples inside the nightwatch examples folder; feel free |
|
|
173
|
-
// to adapt this to your own project needs |
|
|
174
|
-
/// ///////////////////////////////////////////////////////////////////////////////
|
|
175
|
-
'cucumber-js': {
|
|
176
|
-
src_folders: ['examples/cucumber-js/features/step_definitions'],
|
|
177
|
-
|
|
178
|
-
test_runner: {
|
|
179
|
-
// set cucumber as the runner
|
|
180
|
-
type: 'cucumber',
|
|
181
|
-
|
|
182
|
-
// define cucumber specific options
|
|
183
|
-
options: {
|
|
184
|
-
// set the feature path
|
|
185
|
-
feature_path: 'node_modules/nightwatch/examples/cucumber-js/*/*.feature',
|
|
186
|
-
|
|
187
|
-
// start the webdriver session automatically (enabled by default)
|
|
188
|
-
// auto_start_session: true
|
|
189
|
-
|
|
190
|
-
// use parallel execution in Cucumber
|
|
191
|
-
// parallel: 2 // set number of workers to use (can also be defined in the cli as --parallel 2
|
|
192
|
-
},
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
|
|
196
|
-
/// ///////////////////////////////////////////////////////////////////////////////
|
|
197
|
-
// Configuration for when using the browserstack.com cloud service |
|
|
198
|
-
// |
|
|
199
|
-
// Please set the username and access key by setting the environment variables: |
|
|
200
|
-
// - BROWSERSTACK_USER |
|
|
201
|
-
// - BROWSERSTACK_KEY |
|
|
202
|
-
// .env files are supported |
|
|
203
|
-
/// ///////////////////////////////////////////////////////////////////////////////
|
|
204
|
-
browserstack: {
|
|
205
|
-
selenium: {
|
|
206
|
-
host: 'hub-cloud.browserstack.com',
|
|
207
|
-
port: 443,
|
|
208
|
-
},
|
|
209
|
-
// More info on configuring capabilities can be found on:
|
|
210
|
-
// https://www.browserstack.com/automate/capabilities?tag=selenium-4
|
|
211
|
-
desiredCapabilities: {
|
|
212
|
-
'bstack:options': {
|
|
213
|
-
userName: '${BROWSERSTACK_USER}',
|
|
214
|
-
accessKey: '${BROWSERSTACK_KEY}',
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
|
|
218
|
-
disable_error_log: true,
|
|
219
|
-
webdriver: {
|
|
220
|
-
timeout_options: {
|
|
221
|
-
timeout: 15000,
|
|
222
|
-
retry_attempts: 3,
|
|
223
|
-
},
|
|
224
|
-
keep_alive: true,
|
|
225
|
-
start_process: false,
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
|
|
229
|
-
'browserstack.local': {
|
|
230
|
-
extends: 'browserstack',
|
|
231
|
-
desiredCapabilities: {
|
|
232
|
-
'browserstack.local': true,
|
|
233
|
-
},
|
|
234
|
-
},
|
|
235
|
-
|
|
236
|
-
'browserstack.chrome': {
|
|
237
|
-
extends: 'browserstack',
|
|
238
|
-
desiredCapabilities: {
|
|
239
|
-
browserName: 'chrome',
|
|
240
|
-
chromeOptions: {
|
|
241
|
-
w3c: true,
|
|
242
|
-
},
|
|
243
|
-
},
|
|
244
|
-
},
|
|
245
|
-
|
|
246
|
-
'browserstack.firefox': {
|
|
247
|
-
extends: 'browserstack',
|
|
248
|
-
desiredCapabilities: {
|
|
249
|
-
browserName: 'firefox',
|
|
250
|
-
},
|
|
251
|
-
},
|
|
252
|
-
|
|
253
|
-
'browserstack.ie': {
|
|
254
|
-
extends: 'browserstack',
|
|
255
|
-
desiredCapabilities: {
|
|
256
|
-
browserName: 'internet explorer',
|
|
257
|
-
browserVersion: '11.0',
|
|
258
|
-
},
|
|
259
|
-
},
|
|
260
|
-
|
|
261
|
-
'browserstack.safari': {
|
|
262
|
-
extends: 'browserstack',
|
|
263
|
-
desiredCapabilities: {
|
|
264
|
-
browserName: 'safari',
|
|
265
|
-
},
|
|
266
|
-
},
|
|
267
|
-
|
|
268
|
-
'browserstack.local_chrome': {
|
|
269
|
-
extends: 'browserstack.local',
|
|
270
|
-
desiredCapabilities: {
|
|
271
|
-
browserName: 'chrome',
|
|
272
|
-
},
|
|
273
|
-
},
|
|
274
|
-
|
|
275
|
-
'browserstack.local_firefox': {
|
|
276
|
-
extends: 'browserstack.local',
|
|
277
|
-
desiredCapabilities: {
|
|
278
|
-
browserName: 'firefox',
|
|
279
|
-
},
|
|
280
|
-
},
|
|
281
|
-
/// ///////////////////////////////////////////////////////////////////////////////
|
|
282
|
-
// Configuration for when using the Selenium service, either locally or remote, |
|
|
283
|
-
// like Selenium Grid |
|
|
284
|
-
/// ///////////////////////////////////////////////////////////////////////////////
|
|
285
|
-
selenium_server: {
|
|
286
|
-
// Selenium Server is running locally and is managed by Nightwatch
|
|
287
|
-
selenium: {
|
|
288
|
-
start_process: true,
|
|
289
|
-
port: 4444,
|
|
290
|
-
server_path: (Services.seleniumServer ? Services.seleniumServer.path : ''),
|
|
291
|
-
cli_args: {
|
|
292
|
-
'webdriver.gecko.driver': (Services.geckodriver ? Services.geckodriver.path : ''),
|
|
293
|
-
'webdriver.chrome.driver': (Services.chromedriver ? Services.chromedriver.path : ''),
|
|
294
|
-
},
|
|
295
|
-
},
|
|
296
|
-
},
|
|
297
|
-
|
|
298
|
-
'selenium.chrome': {
|
|
299
|
-
extends: 'selenium_server',
|
|
300
|
-
desiredCapabilities: {
|
|
301
|
-
browserName: 'chrome',
|
|
302
|
-
chromeOptions: {
|
|
303
|
-
w3c: true,
|
|
304
|
-
},
|
|
64
|
+
selenium_server: {
|
|
65
|
+
// Selenium Server is running locally and is managed by Nightwatch
|
|
66
|
+
selenium: {
|
|
67
|
+
start_process: true,
|
|
68
|
+
port: 4444,
|
|
69
|
+
server_path: (Services.seleniumServer ? Services.seleniumServer.path : ''),
|
|
70
|
+
cli_args: {
|
|
71
|
+
'webdriver.gecko.driver': (Services.geckodriver ? Services.geckodriver.path : ''),
|
|
72
|
+
'webdriver.chrome.driver': (Services.chromedriver ? Services.chromedriver.path : ''),
|
|
305
73
|
},
|
|
306
74
|
},
|
|
75
|
+
},
|
|
307
76
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
// '-headless',
|
|
315
|
-
// '-verbose'
|
|
316
|
-
],
|
|
317
|
-
},
|
|
77
|
+
'selenium.chrome': {
|
|
78
|
+
extends: 'selenium_server',
|
|
79
|
+
desiredCapabilities: {
|
|
80
|
+
browserName: 'chrome',
|
|
81
|
+
chromeOptions: {
|
|
82
|
+
w3c: true,
|
|
318
83
|
},
|
|
319
84
|
},
|
|
320
|
-
}
|
|
85
|
+
}
|
|
321
86
|
};
|
|
322
87
|
|
|
323
88
|
function loadServices() {
|
|
324
89
|
try {
|
|
325
90
|
Services.seleniumServer = require('selenium-server');
|
|
326
|
-
} catch (err) {}
|
|
91
|
+
} catch (err) { }
|
|
327
92
|
|
|
328
93
|
try {
|
|
329
94
|
Services.chromedriver = require('chromedriver');
|
|
330
|
-
} catch (err) {}
|
|
95
|
+
} catch (err) { }
|
|
331
96
|
|
|
332
97
|
try {
|
|
333
98
|
Services.geckodriver = require('geckodriver');
|
|
334
|
-
} catch (err) {}
|
|
335
|
-
}
|
|
99
|
+
} catch (err) { }
|
|
100
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webship-js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "Webship JS automated functional testing.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
@@ -12,7 +12,10 @@
|
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
14
|
"test": "nightwatch --format @cucumber/pretty-formatter --format-options '{\"colorsEnabled\": true}' --format-options '{\"theme\": {\"feature keyword\":[\"bold\",\"blue\"],\"feature name\":[\"blue\",\"underline\"],\"feature description\":[\"blueBright\"],\"scenario keyword\":[\"bold\",\"magenta\"],\"scenario name\":[\"magenta\",\"underline\"],\"step keyword\":[\"bold\",\"green\"],\"step text\":[\"greenBright\",\"italic\"]}}' --format json:./tests/reports/cucumber-report-$( date '+%Y-%m-%d_%H-%M' ).json --format html:./tests/reports/cucumber-report-$( date '+%Y-%m-%d_%H-%M' ).html",
|
|
15
|
-
"lint:js": "node ./node_modules/eslint/bin/eslint.js --config=.eslintrc.json ."
|
|
15
|
+
"lint:js": "node ./node_modules/eslint/bin/eslint.js --config=.eslintrc.json .",
|
|
16
|
+
"build": "webpack",
|
|
17
|
+
"start": "npm run devServer",
|
|
18
|
+
"devServer": "webpack serve --port 8080"
|
|
16
19
|
},
|
|
17
20
|
"repository": {
|
|
18
21
|
"type": "git",
|
|
@@ -31,11 +34,15 @@
|
|
|
31
34
|
"args-parser": "~1.0",
|
|
32
35
|
"eslint": "~8.0",
|
|
33
36
|
"eslint-config-airbnb-base": "~15.0",
|
|
34
|
-
"eslint-plugin-import": "~2.25"
|
|
37
|
+
"eslint-plugin-import": "~2.25",
|
|
38
|
+
"lodash": "~4.17.21",
|
|
39
|
+
"webpack": "~5.0"
|
|
35
40
|
},
|
|
36
41
|
"devDependencies": {
|
|
37
42
|
"chromedriver": "*",
|
|
38
|
-
"geckodriver": "*"
|
|
43
|
+
"geckodriver": "*",
|
|
44
|
+
"webpack-cli": "~5.0",
|
|
45
|
+
"webpack-dev-server": "~4.0"
|
|
39
46
|
},
|
|
40
47
|
"bin": {
|
|
41
48
|
"steplist": "./steplist.js"
|
package/src/index.js
ADDED
package/steplist.js
CHANGED
|
@@ -2,7 +2,21 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const fs = require('fs');
|
|
5
|
-
|
|
5
|
+
var insidProject = false;
|
|
6
|
+
var basePath = '';
|
|
7
|
+
var projectPath = '';
|
|
8
|
+
|
|
9
|
+
const currentPath = process.argv[1].split("node_modules");
|
|
10
|
+
basePath = currentPath[0].substring(0, currentPath[0].lastIndexOf("/"));
|
|
11
|
+
basePath = basePath + '/';
|
|
12
|
+
projectPath = basePath + "node_modules/webship-js/";
|
|
13
|
+
|
|
14
|
+
if(currentPath.length > 1){
|
|
15
|
+
insidProject = true;
|
|
16
|
+
}
|
|
17
|
+
else{
|
|
18
|
+
insidProject = false;
|
|
19
|
+
}
|
|
6
20
|
|
|
7
21
|
/**
|
|
8
22
|
* -----------------------------------------------------
|
|
@@ -11,44 +25,47 @@ const conf = require('./nightwatch.conf.js');
|
|
|
11
25
|
*/
|
|
12
26
|
const { ArgumentParser } = require('argparse');
|
|
13
27
|
const { version } = require('./package.json');
|
|
14
|
-
|
|
28
|
+
|
|
15
29
|
const parser = new ArgumentParser({
|
|
16
30
|
description: 'Argparse example'
|
|
17
31
|
});
|
|
18
32
|
|
|
19
33
|
parser.add_argument('-v', '--version', { action: 'version', version });
|
|
20
|
-
parser.add_argument('-l', '--list',
|
|
21
|
-
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
34
|
+
parser.add_argument('-l', '--list',
|
|
35
|
+
{
|
|
36
|
+
help: 'Display step definitions list without information.',
|
|
37
|
+
action: 'store_true',
|
|
38
|
+
default: true,
|
|
39
|
+
});
|
|
26
40
|
|
|
27
|
-
parser.add_argument('-i', '--
|
|
28
|
-
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
});
|
|
41
|
+
parser.add_argument('-i', '--info',
|
|
42
|
+
{
|
|
43
|
+
help: 'Display step definitions list with information.',
|
|
44
|
+
action: 'store_true',
|
|
45
|
+
});
|
|
32
46
|
|
|
33
|
-
parser.add_argument('-c', '--config',
|
|
34
|
-
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
});
|
|
47
|
+
parser.add_argument('-c', '--config',
|
|
48
|
+
{
|
|
49
|
+
help: 'Add your nightwatch config file, Example: -c="nightwatch.conf.js" OR -c=nightwatch.conf.js OR -c nightwatch.conf.js',
|
|
50
|
+
default: 'nightwatch.conf.js',
|
|
51
|
+
});
|
|
38
52
|
|
|
39
|
-
parser.add_argument('-s', '--src_folders',
|
|
40
|
-
{
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
});
|
|
53
|
+
parser.add_argument('-s', '--src_folders',
|
|
54
|
+
{
|
|
55
|
+
help: 'Add your step definitions folder/s path, Example: -s="path/to/folder1" OR -s="path/to/folder1 path/to/folder2", You can add as much as you want of folder paths',
|
|
56
|
+
default: "",
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
parser.add_argument('-f', '--format',
|
|
60
|
+
{
|
|
61
|
+
help: 'Choose step definitions list format style. \n(1) stdout-spaces. \n(2) stdout-dashes \n(3) html-spaces. \n(4) html-dashes. Example: -f=stdout-dashes OR -f stdout-dashes',
|
|
62
|
+
default: "stdout-spaces",
|
|
63
|
+
});
|
|
44
64
|
|
|
45
|
-
parser.add_argument('-f', '--format',
|
|
46
|
-
{
|
|
47
|
-
help: 'Choose step definitions list format style, just add a number. (1) stdout-space. (2) stdout-dashes. Example: -f=1 OR -f 2',
|
|
48
|
-
default: "1",
|
|
49
|
-
});
|
|
50
|
-
|
|
51
65
|
var argsParse = parser.parse_args();
|
|
66
|
+
if(currentPath.length > 1){
|
|
67
|
+
argsParse.format = 'html-spaces';
|
|
68
|
+
}
|
|
52
69
|
|
|
53
70
|
/**
|
|
54
71
|
* -----------------------------------------------------
|
|
@@ -61,21 +78,23 @@ var argsParse = parser.parse_args();
|
|
|
61
78
|
* (--src_folder) tag added in nodejs command line.
|
|
62
79
|
*/
|
|
63
80
|
let foldersPath = [];
|
|
64
|
-
function setFoldersPath(value) {
|
|
81
|
+
function setFoldersPath(value, type) {
|
|
65
82
|
value.forEach((element) => {
|
|
66
|
-
|
|
83
|
+
var elementPath = '';
|
|
84
|
+
if(insidProject == true && !process.argv.find(element => element == type)){
|
|
85
|
+
elementPath = projectPath + element;
|
|
86
|
+
}
|
|
87
|
+
else if(insidProject == false && !process.argv.find(element => element == type)){
|
|
88
|
+
elementPath = basePath + element;
|
|
89
|
+
}
|
|
90
|
+
else{
|
|
91
|
+
elementPath = element;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
foldersPath.push(elementPath);
|
|
67
95
|
});
|
|
68
96
|
}
|
|
69
97
|
|
|
70
|
-
/**
|
|
71
|
-
* Output Format name variable
|
|
72
|
-
*
|
|
73
|
-
* Set and Get Output Format exist in (--format) tag added
|
|
74
|
-
* in nodejs command line.
|
|
75
|
-
*/
|
|
76
|
-
let outputFormat = 'stdout-spaces';
|
|
77
|
-
function setOutputFormat(value) { outputFormat = value; }
|
|
78
|
-
|
|
79
98
|
/**
|
|
80
99
|
* Start with Function.
|
|
81
100
|
*
|
|
@@ -86,18 +105,18 @@ function setOutputFormat(value) { outputFormat = value; }
|
|
|
86
105
|
* @return {array} The array has only lines startsWith words chosen.
|
|
87
106
|
*/
|
|
88
107
|
function startWith(stepsList) {
|
|
89
|
-
if(argsParse.
|
|
108
|
+
if (argsParse.info == true) {
|
|
90
109
|
return (stepsList.startsWith('Given') ||
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
110
|
+
stepsList.startsWith('Then') ||
|
|
111
|
+
stepsList.startsWith('When') ||
|
|
112
|
+
stepsList.startsWith('/**') ||
|
|
113
|
+
stepsList.startsWith('* ') ||
|
|
114
|
+
stepsList.startsWith('*/'));
|
|
96
115
|
}
|
|
97
|
-
else if(argsParse.list == true){
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
116
|
+
else if (argsParse.list == true) {
|
|
117
|
+
return (stepsList.startsWith('Given') ||
|
|
118
|
+
stepsList.startsWith('Then') ||
|
|
119
|
+
stepsList.startsWith('When'));
|
|
101
120
|
}
|
|
102
121
|
}
|
|
103
122
|
|
|
@@ -134,9 +153,12 @@ function stepsCleanList(stepsList) {
|
|
|
134
153
|
} else if (!element.startsWith('/**') && !element.startsWith('*/')) {
|
|
135
154
|
const filter1 = element.split('$/');
|
|
136
155
|
const filter2 = filter1[0].replace('(/^', ' ');
|
|
137
|
-
|
|
156
|
+
|
|
138
157
|
if (stepComment !== '') {
|
|
139
|
-
if (
|
|
158
|
+
if (argsParse.format.startsWith('html')){
|
|
159
|
+
stepComment = `<div class="info">${stepComment}</div>\r\n`;
|
|
160
|
+
newStepsList.push(`${filter2}\r\n${stepComment}`);
|
|
161
|
+
}
|
|
140
162
|
else newStepsList.push(`${filter2}\r\n${stepComment}`);
|
|
141
163
|
} else newStepsList.push(filter2);
|
|
142
164
|
|
|
@@ -149,7 +171,7 @@ function stepsCleanList(stepsList) {
|
|
|
149
171
|
function srcFolderPaths(path) {
|
|
150
172
|
const paths = path.split(' ');
|
|
151
173
|
|
|
152
|
-
setFoldersPath(paths);
|
|
174
|
+
setFoldersPath(paths, '-s');
|
|
153
175
|
}
|
|
154
176
|
|
|
155
177
|
/**
|
|
@@ -159,18 +181,28 @@ function srcFolderPaths(path) {
|
|
|
159
181
|
* all folders contain step definitions js files.
|
|
160
182
|
*/
|
|
161
183
|
|
|
162
|
-
|
|
184
|
+
if(insidProject == true && !process.argv.find(element => element == "-c")){
|
|
185
|
+
argsParse.config = projectPath + argsParse.config;
|
|
186
|
+
}
|
|
187
|
+
else if(insidProject == false && !process.argv.find(element => element == "-c")){
|
|
188
|
+
argsParse.config = basePath + argsParse.config;
|
|
189
|
+
}
|
|
163
190
|
|
|
164
|
-
|
|
165
|
-
configPathsArray = configPath.src_folders;
|
|
191
|
+
const configPath = require(argsParse.config);
|
|
166
192
|
|
|
167
|
-
|
|
193
|
+
let configPathsArray = [];
|
|
168
194
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
195
|
+
configPathsArray = configPath.src_folders;
|
|
196
|
+
setFoldersPath(configPathsArray, '-c');
|
|
172
197
|
|
|
173
|
-
|
|
198
|
+
if (foldersPath.length === 0) {
|
|
199
|
+
configPathsArray = argsParse.src_folders;
|
|
200
|
+
setFoldersPath(configPathsArray, '-c');
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if(process.argv.find(element => element == '-s')){
|
|
204
|
+
srcFolderPaths(argsParse.src_folders);
|
|
205
|
+
}
|
|
174
206
|
|
|
175
207
|
/**
|
|
176
208
|
* Step definitions list
|
|
@@ -185,7 +217,7 @@ foldersPath.forEach((folderPath) => {
|
|
|
185
217
|
}
|
|
186
218
|
|
|
187
219
|
files.forEach((file) => {
|
|
188
|
-
fs.readFile(
|
|
220
|
+
fs.readFile(`${folderPath}/${file}`, 'utf8', (err, data) => {
|
|
189
221
|
if (err) {
|
|
190
222
|
throw new Error(err);
|
|
191
223
|
}
|
|
@@ -196,11 +228,16 @@ foldersPath.forEach((folderPath) => {
|
|
|
196
228
|
const stepsList = stepsCleanList(stepsStartWith);
|
|
197
229
|
|
|
198
230
|
stepsList.forEach((element) => {
|
|
199
|
-
if (argsParse.format ==
|
|
231
|
+
if (argsParse.format == 'stdout-spaces') {
|
|
200
232
|
console.log(element + '\n');
|
|
201
|
-
} else if (argsParse.format ==
|
|
233
|
+
} else if (argsParse.format == 'stdout-dashes') {
|
|
202
234
|
console.log(element + '\n');
|
|
235
|
+
} else if (argsParse.format == 'html-spaces') {
|
|
236
|
+
console.log('<div>' + element + '</div><br/>');
|
|
237
|
+
} else if (argsParse.format == 'html-dashes') {
|
|
238
|
+
console.log('<div>' + element + '</div><br/>');
|
|
203
239
|
}
|
|
240
|
+
|
|
204
241
|
});
|
|
205
242
|
});
|
|
206
243
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Feature: Example test for "I am on the homepage"
|
|
2
|
+
As a tester
|
|
3
|
+
I want to be able to navigate to the homepage
|
|
4
|
+
So that I can check the welcome message at homepage
|
|
5
|
+
|
|
6
|
+
Scenario: Check the homepage step definition
|
|
7
|
+
Given I am on the homepage
|
|
8
|
+
Then I should see "Welcome to the homepage of the Webship-js Examples"
|
|
9
|
+
|
|
10
|
+
Scenario: Check homepage step definition
|
|
11
|
+
Given I am on homepage
|
|
12
|
+
Then I should see "Welcome to the homepage of the Webship-js Examples"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Feature: Example test for filling text with value
|
|
2
|
+
As a developer
|
|
3
|
+
I want to be able to test when fill input text with value,
|
|
4
|
+
with empty value, value for text, and fill in table
|
|
5
|
+
|
|
6
|
+
Scenario: Check fill in input field with value
|
|
7
|
+
Given I am on homepage
|
|
8
|
+
When I go to "test--when--i-fill-in.html"
|
|
9
|
+
When I fill in "Username" with "webshipco"
|
|
10
|
+
When I fill in "Password" with "1234"
|
|
11
|
+
When I press "Login"
|
|
12
|
+
Then I should see "You enter Username: webshipco and Password: 1234"
|
|
13
|
+
|
|
14
|
+
Scenario: Check fill in input field with empty value
|
|
15
|
+
Given I am on homepage
|
|
16
|
+
When I go to "test--when--i-fill-in.html"
|
|
17
|
+
When I fill in "Username" with:
|
|
18
|
+
When I press "Login"
|
|
19
|
+
Then I should see "You enter Username: "
|
|
20
|
+
|
|
21
|
+
Scenario: Check fill in value for input field
|
|
22
|
+
Given I am on homepage
|
|
23
|
+
When I go to "test--when--i-fill-in.html"
|
|
24
|
+
When I fill in "webshipco" for "Username"
|
|
25
|
+
When I fill in "1234" for "Password"
|
|
26
|
+
When I press "Login"
|
|
27
|
+
Then I should see "You enter Username: webshipco and Password: 1234"
|
|
28
|
+
|
|
29
|
+
Scenario: Check fill in table of input fields
|
|
30
|
+
Given I am on homepage
|
|
31
|
+
When I go to "test--when--i-fill-in.html"
|
|
32
|
+
When I fill in the following:
|
|
33
|
+
| username | webshipco |
|
|
34
|
+
| password | 1234 |
|
|
35
|
+
When I press "Login"
|
|
36
|
+
Then I should see "You enter Username: webshipco and Password: 1234"
|