webship-js 1.0.0
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/README.md
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
const Services = {}; loadServices();
|
|
2
|
+
|
|
3
|
+
// _ _ _ _ _ _ _
|
|
4
|
+
// | \ | |(_) | | | | | | | |
|
|
5
|
+
// | \| | _ __ _ | |__ | |_ __ __ __ _ | |_ ___ | |__
|
|
6
|
+
// | . ` || | / _` || '_ \ | __|\ \ /\ / / / _` || __| / __|| '_ \
|
|
7
|
+
// | |\ || || (_| || | | || |_ \ V V / | (_| || |_ | (__ | | | |
|
|
8
|
+
// \_| \_/|_| \__, ||_| |_| \__| \_/\_/ \__,_| \__| \___||_| |_|
|
|
9
|
+
// __/ |
|
|
10
|
+
// |___/
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
// An array of folders (excluding subfolders) where your tests are located;
|
|
14
|
+
// if this is not specified, the test source must be passed as the second argument to the test runner.
|
|
15
|
+
src_folders: ['tests/step-definitions'],
|
|
16
|
+
|
|
17
|
+
// See https://nightwatchjs.org/guide/working-with-page-objects/
|
|
18
|
+
page_objects_path: '',
|
|
19
|
+
|
|
20
|
+
// 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: {},
|
|
30
|
+
|
|
31
|
+
test_runner: {
|
|
32
|
+
type: 'cucumber',
|
|
33
|
+
options: {
|
|
34
|
+
feature_path: 'tests/features/*.feature',
|
|
35
|
+
additional_config: '',
|
|
36
|
+
parallel: 2
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
test_settings: {
|
|
42
|
+
default: {
|
|
43
|
+
disable_error_log: false,
|
|
44
|
+
launch_url: 'https://nightwatchjs.org',
|
|
45
|
+
|
|
46
|
+
screenshots: {
|
|
47
|
+
enabled: false,
|
|
48
|
+
path: 'screens',
|
|
49
|
+
on_failure: true
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
desiredCapabilities: {
|
|
53
|
+
browserName: 'firefox'
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
webdriver: {
|
|
57
|
+
start_process: true,
|
|
58
|
+
server_path: ''
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
safari: {
|
|
63
|
+
desiredCapabilities: {
|
|
64
|
+
browserName: 'safari',
|
|
65
|
+
alwaysMatch: {
|
|
66
|
+
acceptInsecureCerts: false
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
webdriver: {
|
|
70
|
+
start_process: true,
|
|
71
|
+
server_path: ''
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
firefox: {
|
|
76
|
+
desiredCapabilities: {
|
|
77
|
+
browserName: 'firefox',
|
|
78
|
+
alwaysMatch: {
|
|
79
|
+
acceptInsecureCerts: true,
|
|
80
|
+
'moz:firefoxOptions': {
|
|
81
|
+
args: [
|
|
82
|
+
// '-headless',
|
|
83
|
+
// '-verbose'
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
webdriver: {
|
|
89
|
+
start_process: true,
|
|
90
|
+
server_path: '',
|
|
91
|
+
cli_args: [
|
|
92
|
+
// very verbose geckodriver logs
|
|
93
|
+
// '-vv'
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
chrome: {
|
|
99
|
+
desiredCapabilities: {
|
|
100
|
+
browserName: 'chrome',
|
|
101
|
+
'goog:chromeOptions': {
|
|
102
|
+
// More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
|
|
103
|
+
//
|
|
104
|
+
// w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
|
|
105
|
+
w3c: true,
|
|
106
|
+
args: [
|
|
107
|
+
//'--no-sandbox',
|
|
108
|
+
//'--ignore-certificate-errors',
|
|
109
|
+
//'--allow-insecure-localhost',
|
|
110
|
+
//'--headless'
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
webdriver: {
|
|
116
|
+
start_process: true,
|
|
117
|
+
server_path: '',
|
|
118
|
+
cli_args: [
|
|
119
|
+
// --verbose
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
edge: {
|
|
125
|
+
desiredCapabilities: {
|
|
126
|
+
browserName: 'MicrosoftEdge',
|
|
127
|
+
'ms:edgeOptions': {
|
|
128
|
+
w3c: true,
|
|
129
|
+
// More info on EdgeDriver: https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/capabilities-edge-options
|
|
130
|
+
args: [
|
|
131
|
+
//'--headless'
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
webdriver: {
|
|
137
|
+
start_process: true,
|
|
138
|
+
// Download msedgedriver from https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/
|
|
139
|
+
// and set the location below:
|
|
140
|
+
server_path: '',
|
|
141
|
+
cli_args: [
|
|
142
|
+
// --verbose
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
//////////////////////////////////////////////////////////////////////////////////
|
|
148
|
+
// Configuration for when using cucumber-js (https://cucumber.io) |
|
|
149
|
+
// |
|
|
150
|
+
// It uses the bundled examples inside the nightwatch examples folder; feel free |
|
|
151
|
+
// to adapt this to your own project needs |
|
|
152
|
+
//////////////////////////////////////////////////////////////////////////////////
|
|
153
|
+
'cucumber-js': {
|
|
154
|
+
src_folders: ['examples/cucumber-js/features/step_definitions'],
|
|
155
|
+
|
|
156
|
+
test_runner: {
|
|
157
|
+
// set cucumber as the runner
|
|
158
|
+
type: 'cucumber',
|
|
159
|
+
|
|
160
|
+
// define cucumber specific options
|
|
161
|
+
options: {
|
|
162
|
+
//set the feature path
|
|
163
|
+
feature_path: 'node_modules/nightwatch/examples/cucumber-js/*/*.feature'
|
|
164
|
+
|
|
165
|
+
// start the webdriver session automatically (enabled by default)
|
|
166
|
+
// auto_start_session: true
|
|
167
|
+
|
|
168
|
+
// use parallel execution in Cucumber
|
|
169
|
+
// parallel: 2 // set number of workers to use (can also be defined in the cli as --parallel 2
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
//////////////////////////////////////////////////////////////////////////////////
|
|
175
|
+
// Configuration for when using the browserstack.com cloud service |
|
|
176
|
+
// |
|
|
177
|
+
// Please set the username and access key by setting the environment variables: |
|
|
178
|
+
// - BROWSERSTACK_USER |
|
|
179
|
+
// - BROWSERSTACK_KEY |
|
|
180
|
+
// .env files are supported |
|
|
181
|
+
//////////////////////////////////////////////////////////////////////////////////
|
|
182
|
+
browserstack: {
|
|
183
|
+
selenium: {
|
|
184
|
+
host: 'hub-cloud.browserstack.com',
|
|
185
|
+
port: 443
|
|
186
|
+
},
|
|
187
|
+
// More info on configuring capabilities can be found on:
|
|
188
|
+
// https://www.browserstack.com/automate/capabilities?tag=selenium-4
|
|
189
|
+
desiredCapabilities: {
|
|
190
|
+
'bstack:options': {
|
|
191
|
+
userName: '${BROWSERSTACK_USER}',
|
|
192
|
+
accessKey: '${BROWSERSTACK_KEY}'
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
disable_error_log: true,
|
|
197
|
+
webdriver: {
|
|
198
|
+
timeout_options: {
|
|
199
|
+
timeout: 15000,
|
|
200
|
+
retry_attempts: 3
|
|
201
|
+
},
|
|
202
|
+
keep_alive: true,
|
|
203
|
+
start_process: false
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
'browserstack.local': {
|
|
208
|
+
extends: 'browserstack',
|
|
209
|
+
desiredCapabilities: {
|
|
210
|
+
'browserstack.local': true
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
'browserstack.chrome': {
|
|
215
|
+
extends: 'browserstack',
|
|
216
|
+
desiredCapabilities: {
|
|
217
|
+
browserName: 'chrome',
|
|
218
|
+
chromeOptions: {
|
|
219
|
+
w3c: true
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
'browserstack.firefox': {
|
|
225
|
+
extends: 'browserstack',
|
|
226
|
+
desiredCapabilities: {
|
|
227
|
+
browserName: 'firefox'
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
|
|
231
|
+
'browserstack.ie': {
|
|
232
|
+
extends: 'browserstack',
|
|
233
|
+
desiredCapabilities: {
|
|
234
|
+
browserName: 'internet explorer',
|
|
235
|
+
browserVersion: '11.0'
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
|
|
239
|
+
'browserstack.safari': {
|
|
240
|
+
extends: 'browserstack',
|
|
241
|
+
desiredCapabilities: {
|
|
242
|
+
browserName: 'safari'
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
'browserstack.local_chrome': {
|
|
247
|
+
extends: 'browserstack.local',
|
|
248
|
+
desiredCapabilities: {
|
|
249
|
+
browserName: 'chrome'
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
|
|
253
|
+
'browserstack.local_firefox': {
|
|
254
|
+
extends: 'browserstack.local',
|
|
255
|
+
desiredCapabilities: {
|
|
256
|
+
browserName: 'firefox'
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
//////////////////////////////////////////////////////////////////////////////////
|
|
260
|
+
// Configuration for when using the Selenium service, either locally or remote, |
|
|
261
|
+
// like Selenium Grid |
|
|
262
|
+
//////////////////////////////////////////////////////////////////////////////////
|
|
263
|
+
selenium_server: {
|
|
264
|
+
// Selenium Server is running locally and is managed by Nightwatch
|
|
265
|
+
selenium: {
|
|
266
|
+
start_process: true,
|
|
267
|
+
port: 4444,
|
|
268
|
+
server_path: (Services.seleniumServer ? Services.seleniumServer.path : ''),
|
|
269
|
+
cli_args: {
|
|
270
|
+
'webdriver.gecko.driver': (Services.geckodriver ? Services.geckodriver.path : ''),
|
|
271
|
+
'webdriver.chrome.driver': (Services.chromedriver ? Services.chromedriver.path : '')
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
|
|
276
|
+
'selenium.chrome': {
|
|
277
|
+
extends: 'selenium_server',
|
|
278
|
+
desiredCapabilities: {
|
|
279
|
+
browserName: 'chrome',
|
|
280
|
+
chromeOptions: {
|
|
281
|
+
w3c: true
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
|
|
286
|
+
'selenium.firefox': {
|
|
287
|
+
extends: 'selenium_server',
|
|
288
|
+
desiredCapabilities: {
|
|
289
|
+
browserName: 'firefox',
|
|
290
|
+
'moz:firefoxOptions': {
|
|
291
|
+
args: [
|
|
292
|
+
// '-headless',
|
|
293
|
+
// '-verbose'
|
|
294
|
+
]
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
function loadServices() {
|
|
302
|
+
try {
|
|
303
|
+
Services.seleniumServer = require('selenium-server');
|
|
304
|
+
} catch (err) {}
|
|
305
|
+
|
|
306
|
+
try {
|
|
307
|
+
Services.chromedriver = require('chromedriver');
|
|
308
|
+
} catch (err) {}
|
|
309
|
+
|
|
310
|
+
try {
|
|
311
|
+
Services.geckodriver = require('geckodriver');
|
|
312
|
+
} catch (err) {}
|
|
313
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "webship-js",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Webship JS automated functional testing.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"directories": {
|
|
7
|
+
"test": "test"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "nightwatch"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/webship/webship-js.git"
|
|
15
|
+
},
|
|
16
|
+
"author": "Ravi Sawlani",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/webship/webship-js/issues"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/webship/webship-js",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"nightwatch": "~2",
|
|
24
|
+
"@cucumber/cucumber": "*",
|
|
25
|
+
"chromedriver": "*",
|
|
26
|
+
"cucumber-pretty": "*",
|
|
27
|
+
"geckodriver": "*"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const {Given} = require('@cucumber/cucumber');
|
|
2
|
+
const {When, Before} = require('@cucumber/cucumber');
|
|
3
|
+
const {Then} = require('@cucumber/cucumber');
|
|
4
|
+
|
|
5
|
+
Given(/^I go to "([^"]*)?"$/, function(url) {
|
|
6
|
+
return browser.url(url);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
Then(/^I should( not)* see "([^"]*)?"$/, function(negativeCase, expectedText) {
|
|
10
|
+
if (negativeCase) {
|
|
11
|
+
return browser.assert.not.textContains('body', expectedText);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return browser.assert.textContains('body', expectedText);
|
|
15
|
+
});
|