webship-js 1.0.11 → 1.0.13
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 +103 -0
- package/assets/config_templates/github-linux-chrome.conf.js +114 -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 +27 -0
- package/examples/main.js +17 -0
- package/examples/test--then--i-should--not--see-text-in-element.html +48 -0
- package/examples/test--when--i-check-uncheck-checkbox.html +45 -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-assertions/smartElementContains.js +54 -0
- package/lib/custom-commands/smartCheckItem.js +39 -0
- package/lib/custom-commands/smartSelectOption.js +33 -0
- package/lib/custom-commands/smartUncheckItem.js +45 -0
- package/lib/get-element.js +65 -0
- package/nightwatch.conf.js +27 -259
- package/package.json +11 -4
- package/src/index.js +10 -0
- package/tests/features/test--given--i-am-on-homepage.feature +12 -0
- package/tests/features/test--then--i-should--not--see-text-in-element.feature +13 -0
- package/tests/features/test--then--i-should-be-on-page.feature +10 -0
- package/tests/features/test--then--i-should-be-on-the-homepage.feature +9 -0
- package/tests/features/test--then--the-response-should-contain.feature +12 -0
- package/tests/features/test--when--i-check-checkbox.feature +17 -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/features/test--when--i-uncheck-checkbox.feature +20 -0
- package/tests/reports/cucumber-report.html +0 -0
- package/tests/reports/cucumber-report.json +0 -0
- package/tests/step-definitions/webship.js +232 -11
- package/webpack.config.js +17 -0
- package/webship-init.js +75 -0
- package/tests/features/check-webshipco-site.feature +0 -8
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports.assertion = function (negativeCase, expectedText, element) {
|
|
3
|
+
|
|
4
|
+
browser.element('css selector', element, function (result) {
|
|
5
|
+
if (result.status === 0) {
|
|
6
|
+
if (negativeCase) {
|
|
7
|
+
return browser.assert.not.textContains(element, expectedText);
|
|
8
|
+
}
|
|
9
|
+
return browser.assert.textContains(element, expectedText);
|
|
10
|
+
} else {
|
|
11
|
+
browser.element('css selector', '#' + element, function (result) {
|
|
12
|
+
if (result.status === 0) {
|
|
13
|
+
if (negativeCase) {
|
|
14
|
+
return browser.assert.not.textContains(element, expectedText);
|
|
15
|
+
}
|
|
16
|
+
return browser.assert.textContains(element, expectedText);
|
|
17
|
+
} else {
|
|
18
|
+
browser.element('css selector', 'input[name="' + element + '"]', function (result) {
|
|
19
|
+
if (result.status === 0) {
|
|
20
|
+
if (negativeCase) {
|
|
21
|
+
return browser.assert.not.textContains(element, expectedText);
|
|
22
|
+
}
|
|
23
|
+
return browser.assert.textContains(element, expectedText);
|
|
24
|
+
} else {
|
|
25
|
+
browser.element('css selector', 'input[value="' + element + '"]', function (result) {
|
|
26
|
+
if (result.status === 0) {
|
|
27
|
+
if (negativeCase) {
|
|
28
|
+
return browser.assert.not.textContains(element, expectedText);
|
|
29
|
+
}
|
|
30
|
+
return browser.assert.textContains(element, expectedText);
|
|
31
|
+
} else {
|
|
32
|
+
browser.elements('css selector', 'label', function (elements) {
|
|
33
|
+
elements.value.forEach(function (elementsObj) {
|
|
34
|
+
browser.elementIdText(elementsObj.ELEMENT, function (result) {
|
|
35
|
+
if (result.value == element) {
|
|
36
|
+
browser.getAttribute(elementsObj, "for", function (forVal) {
|
|
37
|
+
if (negativeCase) {
|
|
38
|
+
return browser.assert.not.textContains('#' + forVal.value, expectedText);
|
|
39
|
+
}
|
|
40
|
+
return browser.assert.textContains('#' + forVal.value, expectedText);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports.command = function (item) {
|
|
3
|
+
|
|
4
|
+
browser.element('css selector', item, function (result) {
|
|
5
|
+
if (result.status === 0) {
|
|
6
|
+
return browser.setAttribute(item, 'checked', true);
|
|
7
|
+
} else {
|
|
8
|
+
browser.element('css selector', '#' + item, function (result) {
|
|
9
|
+
if (result.status === 0) {
|
|
10
|
+
return browser.setAttribute('#' + item, 'checked', true);
|
|
11
|
+
} else {
|
|
12
|
+
browser.element('css selector', 'input[name="' + item + '"]', function (result) {
|
|
13
|
+
if (result.status === 0) {
|
|
14
|
+
return browser.setAttribute('input[name="' + item + '"]', 'checked', true);
|
|
15
|
+
} else {
|
|
16
|
+
browser.element('css selector', 'input[value="' + item + '"]', function (result) {
|
|
17
|
+
if (result.status === 0) {
|
|
18
|
+
return browser.setAttribute('input[value="' + item + '"]', 'checked', true);
|
|
19
|
+
} else {
|
|
20
|
+
browser.elements('css selector', 'label', function (elements) {
|
|
21
|
+
elements.value.forEach(function (elementsObj) {
|
|
22
|
+
browser.elementIdText(elementsObj.ELEMENT, function (result) {
|
|
23
|
+
if (result.value == item) {
|
|
24
|
+
browser.getAttribute(elementsObj, "for", function (forVal) {
|
|
25
|
+
return browser.setAttribute('#' + forVal.value, 'checked', true);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports.command = function (option, selectBox) {
|
|
3
|
+
|
|
4
|
+
browser.element('css selector', selectBox, function (result) {
|
|
5
|
+
if (result.status === 0) {
|
|
6
|
+
return browser.click(selectBox + ' option[value=' + option + ']');
|
|
7
|
+
} else {
|
|
8
|
+
browser.element('css selector', '#' + selectBox, function (result) {
|
|
9
|
+
if (result.status === 0) {
|
|
10
|
+
return browser.click('#' + selectBox + ' option[value=' + option + ']');
|
|
11
|
+
} else {
|
|
12
|
+
browser.element('css selector', 'select[name=' + selectBox + ']', function (result) {
|
|
13
|
+
if (result.status === 0) {
|
|
14
|
+
return browser.click('select[name=' + selectBox + ']' + ' option[value=' + option + ']');
|
|
15
|
+
} else {
|
|
16
|
+
browser.elements('css selector', 'label', function (elements) {
|
|
17
|
+
elements.value.forEach(function (elementsObj) {
|
|
18
|
+
browser.elementIdText(elementsObj.ELEMENT, function (result) {
|
|
19
|
+
if (result.value == selectBox) {
|
|
20
|
+
browser.getAttribute(elementsObj, "for", function (forVal) {
|
|
21
|
+
return browser.click('#' + forVal.value + ' option[value=' + option + ']');
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports.command = function (item) {
|
|
3
|
+
|
|
4
|
+
browser.element('css selector', item, function (result) {
|
|
5
|
+
if (result.status === 0) {
|
|
6
|
+
browser.setAttribute(item, 'checked', false);
|
|
7
|
+
return browser.click(item);
|
|
8
|
+
} else {
|
|
9
|
+
browser.element('css selector', '#' + item, function (result) {
|
|
10
|
+
if (result.status === 0) {
|
|
11
|
+
browser.setAttribute('#' + item, 'checked', false);
|
|
12
|
+
return browser.click('#' + item);
|
|
13
|
+
} else {
|
|
14
|
+
browser.element('css selector', 'input[name=' + item + ']', function (result) {
|
|
15
|
+
if (result.status === 0) {
|
|
16
|
+
browser.setAttribute('input[name=' + item + ']', 'checked', false);
|
|
17
|
+
return browser.click('input[name=' + item + ']');
|
|
18
|
+
|
|
19
|
+
} else {
|
|
20
|
+
browser.element('css selector', 'input[value="' + item + '"]', function (result) {
|
|
21
|
+
if (result.status === 0) {
|
|
22
|
+
browser.setAttribute('input[value="' + item + '"]', 'checked', false);
|
|
23
|
+
return browser.click('input[value="' + item + '"]');
|
|
24
|
+
} else {
|
|
25
|
+
browser.elements('css selector', 'label', function (elements) {
|
|
26
|
+
elements.value.forEach(function (elementsObj) {
|
|
27
|
+
browser.elementIdText(elementsObj.ELEMENT, function (result) {
|
|
28
|
+
if (result.value == item) {
|
|
29
|
+
browser.getAttribute(elementsObj, "for", function (forVal) {
|
|
30
|
+
browser.setAttribute('#' + forVal.value, 'checked', false);
|
|
31
|
+
return browser.click('#' + forVal.value);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
/**
|
|
3
|
+
* Fill the Input Box With the Value
|
|
4
|
+
*
|
|
5
|
+
* Function to find input by
|
|
6
|
+
* id|class|name|placeholder|label
|
|
7
|
+
* and fill it with sent value
|
|
8
|
+
*/
|
|
9
|
+
fillInputWithValue: function (field, value) {
|
|
10
|
+
let element = null;
|
|
11
|
+
let selector = field;
|
|
12
|
+
|
|
13
|
+
browser.element('css selector', selector, function(result){
|
|
14
|
+
if(result.status == 0){
|
|
15
|
+
return browser.setValue(selector, value);
|
|
16
|
+
}
|
|
17
|
+
else{
|
|
18
|
+
selector = '#' + field;
|
|
19
|
+
browser.element('css selector', selector, function(result){
|
|
20
|
+
if(result.status == 0){
|
|
21
|
+
return browser.setValue(selector, value);
|
|
22
|
+
}
|
|
23
|
+
else{
|
|
24
|
+
selector = '.' + field;
|
|
25
|
+
browser.element('css selector', selector, function(result){
|
|
26
|
+
if(result.status == 0){
|
|
27
|
+
return browser.setValue(selector, value);
|
|
28
|
+
}
|
|
29
|
+
else{
|
|
30
|
+
selector = 'input[name=' + field + ']';
|
|
31
|
+
browser.element('css selector', selector, function(result){
|
|
32
|
+
if(result.status == 0){
|
|
33
|
+
return browser.setValue(selector, value);
|
|
34
|
+
}
|
|
35
|
+
else{
|
|
36
|
+
selector = "input[placeholder='" + field + "']";
|
|
37
|
+
browser.element('css selector', selector, function(result){
|
|
38
|
+
if(result.status == 0){
|
|
39
|
+
return browser.setValue(selector, value);
|
|
40
|
+
}
|
|
41
|
+
else{
|
|
42
|
+
browser.elements('css selector', 'label', function (elements) {
|
|
43
|
+
for (let i = 0; i < elements.value.length; i++) {
|
|
44
|
+
this.elementIdText(elements.value[i].ELEMENT, function (result) {
|
|
45
|
+
if (result.value === field) {
|
|
46
|
+
element = elements.value[i].ELEMENT;
|
|
47
|
+
browser.elementIdAttribute(element, 'for', function(eleAttribute){
|
|
48
|
+
return browser.setValue('#' + eleAttribute.value, value);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|
package/nightwatch.conf.js
CHANGED
|
@@ -1,32 +1,15 @@
|
|
|
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/
|
|
18
|
-
|
|
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: '',
|
|
8
|
+
// See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
|
|
9
|
+
custom_commands_path: './lib/custom-commands',
|
|
28
10
|
|
|
29
|
-
|
|
11
|
+
// See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-assertions.html
|
|
12
|
+
custom_assertions_path: './lib/custom-assertions',
|
|
30
13
|
|
|
31
14
|
test_runner: {
|
|
32
15
|
type: 'cucumber',
|
|
@@ -35,12 +18,11 @@ module.exports = {
|
|
|
35
18
|
additional_config: '',
|
|
36
19
|
parallel: 2,
|
|
37
20
|
},
|
|
38
|
-
|
|
39
21
|
},
|
|
40
22
|
|
|
41
23
|
test_settings: {
|
|
42
24
|
default: {
|
|
43
|
-
launch_url: '
|
|
25
|
+
launch_url: 'http://localhost:8080/',
|
|
44
26
|
selenium_port: 4444,
|
|
45
27
|
selenium_host: '127.0.0.1',
|
|
46
28
|
silent: true,
|
|
@@ -80,256 +62,42 @@ module.exports = {
|
|
|
80
62
|
},
|
|
81
63
|
},
|
|
82
64
|
},
|
|
65
|
+
},
|
|
83
66
|
|
|
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
|
-
},
|
|
67
|
+
selenium_server: {
|
|
68
|
+
// Selenium Server is running locally and is managed by Nightwatch
|
|
69
|
+
selenium: {
|
|
70
|
+
start_process: true,
|
|
71
|
+
port: 4444,
|
|
72
|
+
server_path: (Services.seleniumServer ? Services.seleniumServer.path : ''),
|
|
73
|
+
cli_args: {
|
|
74
|
+
'webdriver.gecko.driver': (Services.geckodriver ? Services.geckodriver.path : ''),
|
|
75
|
+
'webdriver.chrome.driver': (Services.chromedriver ? Services.chromedriver.path : ''),
|
|
305
76
|
},
|
|
306
77
|
},
|
|
78
|
+
},
|
|
307
79
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
// '-headless',
|
|
315
|
-
// '-verbose'
|
|
316
|
-
],
|
|
317
|
-
},
|
|
80
|
+
'selenium.chrome': {
|
|
81
|
+
extends: 'selenium_server',
|
|
82
|
+
desiredCapabilities: {
|
|
83
|
+
browserName: 'chrome',
|
|
84
|
+
chromeOptions: {
|
|
85
|
+
w3c: true,
|
|
318
86
|
},
|
|
319
87
|
},
|
|
320
|
-
}
|
|
88
|
+
}
|
|
321
89
|
};
|
|
322
90
|
|
|
323
91
|
function loadServices() {
|
|
324
92
|
try {
|
|
325
93
|
Services.seleniumServer = require('selenium-server');
|
|
326
|
-
} catch (err) {}
|
|
94
|
+
} catch (err) { }
|
|
327
95
|
|
|
328
96
|
try {
|
|
329
97
|
Services.chromedriver = require('chromedriver');
|
|
330
|
-
} catch (err) {}
|
|
98
|
+
} catch (err) { }
|
|
331
99
|
|
|
332
100
|
try {
|
|
333
101
|
Services.geckodriver = require('geckodriver');
|
|
334
|
-
} catch (err) {}
|
|
335
|
-
}
|
|
102
|
+
} catch (err) { }
|
|
103
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webship-js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
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
|
@@ -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,13 @@
|
|
|
1
|
+
Feature: Example test for: Then I should see "text" in the "element" element
|
|
2
|
+
As a developer
|
|
3
|
+
I want to be able to check an element if it has a particular text or not
|
|
4
|
+
|
|
5
|
+
Scenario: Check an element if it has a particular text or not
|
|
6
|
+
Given I am on homepage
|
|
7
|
+
When I go to "test--then--i-should--not--see-text-in-element.html"
|
|
8
|
+
And I fill in "Username" with "user1"
|
|
9
|
+
And I fill in "Password" with "1234"
|
|
10
|
+
Then I should see "user1" in the "Username" element
|
|
11
|
+
When I press "Reset"
|
|
12
|
+
And I fill in "Username" with "user2"
|
|
13
|
+
Then I should not see "user1" in the "Username" element
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Feature: Example test for "Then I should be on 'page'"
|
|
2
|
+
As a tester
|
|
3
|
+
I want to be sure I am on "page"
|
|
4
|
+
|
|
5
|
+
Scenario: Check "Then I should be on the 'page'" step definition
|
|
6
|
+
Given I am on the homepage
|
|
7
|
+
When I go to "about-us.html"
|
|
8
|
+
Then I should be on "about-us.html"
|
|
9
|
+
When I move backward one page
|
|
10
|
+
Then I should be on "/"
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Feature: Example test for "Then I should be on the homepage"
|
|
2
|
+
As a tester
|
|
3
|
+
I want to be sure I am on the homepage
|
|
4
|
+
|
|
5
|
+
Scenario: Check "Then I should be on the homepage" step definition
|
|
6
|
+
Given I am on the homepage
|
|
7
|
+
When I go to "about-us.html"
|
|
8
|
+
And I move backward one page
|
|
9
|
+
Then I should be on the homepage
|