webship-js 1.0.14 → 1.0.17
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 +4 -57
- package/examples/about-us.html +1 -0
- package/examples/index.html +4 -2
- package/examples/test--then--the-checkbox-checked.html +68 -0
- package/examples/test--then--the-element-should_not-contain-cssproperty.html +47 -0
- package/examples/test--when--i-attach-file-to-feild.html +32 -0
- package/examples/test--when--i-press-button.html +2 -1
- package/generate-reports.js +21 -0
- package/lib/custom-assertions/smartCheckboxChecked.js +54 -0
- package/lib/custom-assertions/smartElementContainsCss.js +62 -0
- package/lib/custom-commands/smartCheckItem.js +5 -5
- package/lib/custom-commands/smartFillTextInput.js +56 -0
- package/lib/custom-commands/smartLinkClick.js +12 -0
- package/lib/custom-commands/smartPressButton.js +12 -0
- package/lib/custom-commands/smartUncheckItem.js +0 -6
- package/lib/custom-commands/smartUploadFile.js +38 -0
- package/nightwatch.conf.js +1 -0
- package/package.json +4 -2
- package/tests/features/test--then--i-should-see-an-element.feature +9 -0
- package/tests/features/test--then--i-should-see-text-matching.feature +8 -0
- package/tests/features/test--then--the-checkbox-checked.feature +16 -0
- package/tests/features/test--then--the-element-should_not-contain-cssproperty.feature +12 -0
- package/tests/features/test--then--the-field-should-contain-value.feature +12 -0
- package/tests/features/test--when--i-attach-file-to-feild.feature +10 -0
- package/tests/step-definitions/webship.js +122 -13
- package/tests/upload/webshipco.png +0 -0
- package/webship-init.js +14 -14
- package/lib/get-element.js +0 -65
- package/tests/reports/cucumber-report.html +0 -48
- package/tests/reports/cucumber-report.json +0 -66
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Feature: Example test the checkbox if checked or not
|
|
2
|
+
As a tester
|
|
3
|
+
I want to be able to test uncheck a checkbox item
|
|
4
|
+
|
|
5
|
+
Scenario: Check the "Then checkbox is/should be checked" step definitions
|
|
6
|
+
Given I am on "test--then--the-checkbox-checked.html"
|
|
7
|
+
When I press "Register"
|
|
8
|
+
Then the "PrivacyPolicy" checkbox should not be checked
|
|
9
|
+
And the "rememberMe" checkbox is not checked
|
|
10
|
+
And I should see "Please check Agree to Privacy Policy"
|
|
11
|
+
When I check "PrivacyPolicy"
|
|
12
|
+
And I press "Register"
|
|
13
|
+
Then the checkbox "PrivacyPolicy" should be checked
|
|
14
|
+
And I should see "Registration Done Successfully"
|
|
15
|
+
When I check "rememberMe"
|
|
16
|
+
Then the checkbox "Remember me" is checked
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Feature: Example test element contains Css property and property value expected
|
|
2
|
+
As a developer
|
|
3
|
+
I want to be able to test if element contains Css property and property value expected
|
|
4
|
+
|
|
5
|
+
Scenario: Check element if contains Css property and property value expected
|
|
6
|
+
Given I am on homepage
|
|
7
|
+
When I go to "test--then--the-element-should_not-contain-cssproperty.html"
|
|
8
|
+
Then the "body" element should contain "background-color: lightcoral;"
|
|
9
|
+
And the "Username" element should contain "border: solid 5px red;"
|
|
10
|
+
When I press "Submit"
|
|
11
|
+
Then the "body" element should contain "background-color: white;"
|
|
12
|
+
And the "Username" element should contain "border: solid 5px green;"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Feature: Example test for: Then the "filed" should contain "value"
|
|
2
|
+
As a tester
|
|
3
|
+
I want to be able to check field if has a particular value or not
|
|
4
|
+
|
|
5
|
+
Scenario: Check field if has a particular value 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
|
+
Then the "Username" field should contain "user1"
|
|
10
|
+
When I press "Reset"
|
|
11
|
+
And I fill in "Username" with "user2"
|
|
12
|
+
Then the "Username" field should not contain "user1"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Feature: Example test for "When I attach file to field"
|
|
2
|
+
|
|
3
|
+
As a tester
|
|
4
|
+
I want to be able to attach file (images) to feild
|
|
5
|
+
|
|
6
|
+
Scenario: Check the "When I attach file to feild" step definitions
|
|
7
|
+
Given I am on "test--when--i-attach-file-to-feild.html"
|
|
8
|
+
When I attach the file "../../../tests/upload/webshipco.png" to "#fileUpload"
|
|
9
|
+
When I press "Submit"
|
|
10
|
+
Then I should see "webshipco.png"
|
|
@@ -2,11 +2,8 @@ const { Given } = require('@cucumber/cucumber');
|
|
|
2
2
|
const { When, Before } = require('@cucumber/cucumber');
|
|
3
3
|
const { Then } = require('@cucumber/cucumber');
|
|
4
4
|
|
|
5
|
-
const lib = require('../../lib/get-element.js');
|
|
6
|
-
|
|
7
5
|
/**
|
|
8
6
|
* Opens homepage.
|
|
9
|
-
*
|
|
10
7
|
* Example: Given I am on homepage
|
|
11
8
|
* Example: Given I am on the homepage
|
|
12
9
|
*
|
|
@@ -93,6 +90,7 @@ When(/^I move backward one page$/, function () {
|
|
|
93
90
|
*/
|
|
94
91
|
When(/^I press "([^"]*)?"$/, function (elementValue) {
|
|
95
92
|
return browser.click("[value='" + elementValue + "']");
|
|
93
|
+
// return browser.smartPressButton(elementValue);
|
|
96
94
|
});
|
|
97
95
|
|
|
98
96
|
/**
|
|
@@ -103,7 +101,8 @@ When(/^I press "([^"]*)?"$/, function (elementValue) {
|
|
|
103
101
|
* @When /^I follow "([^"]*)?"$/
|
|
104
102
|
*/
|
|
105
103
|
When(/^I follow "([^"]*)?"$/, function (elementValue) {
|
|
106
|
-
|
|
104
|
+
browser.click("link text", elementValue);
|
|
105
|
+
// return browser.smartLinkClick(elementValue);
|
|
107
106
|
});
|
|
108
107
|
|
|
109
108
|
/**
|
|
@@ -124,7 +123,7 @@ When(/^I reload( the)* page$/, function (url) {
|
|
|
124
123
|
* @When /^I fill in "([^"]*)?" with "([^"]*)?"$/
|
|
125
124
|
*/
|
|
126
125
|
When(/^I fill in "([^"]*)?" with "([^"]*)?"$/, function (field, value) {
|
|
127
|
-
|
|
126
|
+
browser.smartFillTextInput(field, value);
|
|
128
127
|
});
|
|
129
128
|
|
|
130
129
|
/**
|
|
@@ -134,7 +133,7 @@ When(/^I fill in "([^"]*)?" with "([^"]*)?"$/, function (field, value) {
|
|
|
134
133
|
* @When /^I fill in "([^"]*)?" with:$/
|
|
135
134
|
*/
|
|
136
135
|
When(/^I fill in "([^"]*)?" with:$/, function (field) {
|
|
137
|
-
|
|
136
|
+
browser.smartFillTextInput(field, '');
|
|
138
137
|
});
|
|
139
138
|
|
|
140
139
|
/**
|
|
@@ -144,7 +143,7 @@ When(/^I fill in "([^"]*)?" with:$/, function (field) {
|
|
|
144
143
|
* @When /^I fill in "([^"]*)?" for "([^"]*)?"$/
|
|
145
144
|
*/
|
|
146
145
|
When(/^I fill in "([^"]*)?" for "([^"]*)?"$/, function (value, field) {
|
|
147
|
-
|
|
146
|
+
browser.smartFillTextInput(field, value);
|
|
148
147
|
});
|
|
149
148
|
|
|
150
149
|
/**
|
|
@@ -160,9 +159,9 @@ When(/^I fill in "([^"]*)?" for "([^"]*)?"$/, function (value, field) {
|
|
|
160
159
|
*/
|
|
161
160
|
When(/^I fill in the following:$/, function (table) {
|
|
162
161
|
|
|
163
|
-
|
|
162
|
+
browser.smartFillTextInput(table.rawTable[0][0], table.rawTable[0][1]);
|
|
164
163
|
table.rows().forEach(row => {
|
|
165
|
-
|
|
164
|
+
browser.smartFillTextInput(row[0], row[1]);
|
|
166
165
|
});
|
|
167
166
|
});
|
|
168
167
|
|
|
@@ -174,7 +173,7 @@ When(/^I fill in the following:$/, function (table) {
|
|
|
174
173
|
* @When /^I select "([^"]*)?" from "([^"]*)?"$/
|
|
175
174
|
*/
|
|
176
175
|
When(/^I select "([^"]*)?" from "([^"]*)?"$/, function (option, selectBox) {
|
|
177
|
-
browser.
|
|
176
|
+
browser.smartSelectOption(option, selectBox);
|
|
178
177
|
});
|
|
179
178
|
|
|
180
179
|
/**
|
|
@@ -207,7 +206,7 @@ When(/^I uncheck "([^"]*)?"$/, function (item) {
|
|
|
207
206
|
* @Then /^I should be on( the)* homepage$/
|
|
208
207
|
*/
|
|
209
208
|
Then(/^I should be on( the)* homepage$/, function (url) {
|
|
210
|
-
|
|
209
|
+
return browser.assert.urlEquals(browser.launch_url);
|
|
211
210
|
});
|
|
212
211
|
|
|
213
212
|
/**
|
|
@@ -245,5 +244,115 @@ Then(/^the response should( not)* contain "([^"]*)?"$/, function (negativeCase,
|
|
|
245
244
|
* @Then /^I should( not)* see "([^"]*)?" in the "([^"]*)?" element$/
|
|
246
245
|
*/
|
|
247
246
|
Then(/^I should( not)* see "([^"]*)?" in the "([^"]*)?" element$/, function (negativeCase, expectedText, element) {
|
|
248
|
-
|
|
249
|
-
|
|
247
|
+
return browser.assert.smartElementContains(negativeCase, expectedText, element);
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Checks, that page contains text matching specified pattern
|
|
252
|
+
* Example: Then I should see text matching "Bruce Wayne, the vigilante"
|
|
253
|
+
* Example: And I should not see "Bruce Wayne, the vigilante"
|
|
254
|
+
*
|
|
255
|
+
* @Then /^I should( not)* see text matching "([^"]*)?"$/
|
|
256
|
+
*/
|
|
257
|
+
Then(/^I should( not)* see text matching "([^"]*)?"$/, function (negativeCase, expectedText) {
|
|
258
|
+
if (negativeCase) {
|
|
259
|
+
return browser.assert.not.textContains('html', expectedText);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return browser.assert.textContains('html', expectedText);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Checks, that element with specified CSS exists on page
|
|
267
|
+
* Example: Then I should see a "body" element
|
|
268
|
+
* Example: And I should see a "body" element
|
|
269
|
+
*
|
|
270
|
+
* @Then /^I should( not)* see a(n)* "([^"]*)?" element$/
|
|
271
|
+
*/
|
|
272
|
+
Then(/^I should( not)* see a(n)* "([^"]*)?" element$/, function (negativeCase, identification, element) {
|
|
273
|
+
if (negativeCase) {
|
|
274
|
+
return browser.verify.not.visible(element);
|
|
275
|
+
}
|
|
276
|
+
return browser.verify.visible(element);
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Checks, that element with specified CSS contains specified HTML
|
|
281
|
+
* Example: Then the "body" element should contain "color:black;"
|
|
282
|
+
* Example: And the "body" element should contain "color:black;"
|
|
283
|
+
*
|
|
284
|
+
* @Then /^the "([^"]*)?" element should( not)* contain "([^"]*)?"$/
|
|
285
|
+
*/
|
|
286
|
+
Then(/^the "([^"]*)?" element should( not)* contain "([^"]*)?"$/, function (element, negativeCase, elementCss) {
|
|
287
|
+
return browser.assert.smartElementContainsCss(element, negativeCase, elementCss);
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Attaches file to field with specified id|name|label|value
|
|
292
|
+
* Example: When I attach the file "bwayne_profile.png" to "profileImageUpload"
|
|
293
|
+
* Example: And I attach the file "bwayne_profile.png" to "profileImageUpload"
|
|
294
|
+
*
|
|
295
|
+
* @When /^I attach the file "([^"]*)?" to "([^"]*)?"$/
|
|
296
|
+
*/
|
|
297
|
+
When(/^I attach the file "([^"]*)?" to "([^"]*)?"$/, function (fileUrl, element) {
|
|
298
|
+
browser.smartUploadFile(fileUrl, element);
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Checks, that form field with specified id|name|label|value has specified value
|
|
303
|
+
* Example: Then the "username" field should contain "bwayne"
|
|
304
|
+
* Example: And the "username" field should not contain "bwayne"
|
|
305
|
+
*
|
|
306
|
+
* @Then /^the "([^"]*)?" field should( not)* contain "([^"]*)?"$/
|
|
307
|
+
*/
|
|
308
|
+
Then(/^the "([^"]*)?" field should( not)* contain "([^"]*)?"$/, function (field, negativeCase, expectedText) {
|
|
309
|
+
return browser.assert.smartElementContains(negativeCase, expectedText, field);
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Checks, that checkbox with specified id|name|label|value is checked
|
|
314
|
+
* Example: Then the "PrivacyPolicy" checkbox should be checked
|
|
315
|
+
* Example: And the "PrivacyPolicy" checkbox should not be checked
|
|
316
|
+
*
|
|
317
|
+
* @Then /^the "([^"]*)?" checkbox should(not)* be checked$/
|
|
318
|
+
*
|
|
319
|
+
*/
|
|
320
|
+
Then(/^the "([^"]*)?" checkbox should( not)* be checked$/, function (checkbox, negativeCase) {
|
|
321
|
+
return browser.assert.smartCheckboxChecked(checkbox, negativeCase);
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Checks, that checkbox with specified id|name|label|value is checked
|
|
326
|
+
* Example: Then the "Remember Me" checkbox is checked
|
|
327
|
+
* Example: And the "Remember Me" checkbox is not checked
|
|
328
|
+
*
|
|
329
|
+
* @Then /^the "([^"]*)?" checkbox is( not)* checked$/
|
|
330
|
+
*
|
|
331
|
+
*/
|
|
332
|
+
Then(/^the "([^"]*)?" checkbox is( not)* checked$/, function (checkbox, negativeCase) {
|
|
333
|
+
return browser.assert.smartCheckboxChecked(checkbox, negativeCase);
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Checks, that checkbox with specified id|name|label|value is checked
|
|
338
|
+
* Example: Then the checkbox "PrivacyPolicy" should be checked
|
|
339
|
+
* Example: Then the checkbox "PrivacyPolicy" should not be checked
|
|
340
|
+
*
|
|
341
|
+
* @Then /^the checkbox "([^"]*)?" should(not)* be checked$/
|
|
342
|
+
*
|
|
343
|
+
*/
|
|
344
|
+
Then(/^the checkbox "([^"]*)?" should( not)* be checked$/, function (checkbox, negativeCase) {
|
|
345
|
+
return browser.assert.smartCheckboxChecked(checkbox, negativeCase);
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Checks, that checkbox with specified id|name|label|value is checked
|
|
350
|
+
* Example: Then the checkbox "Remember Me" is checked
|
|
351
|
+
* Example: And the checkbox "Remember Me" is not checked
|
|
352
|
+
*
|
|
353
|
+
* @Then /^the checkbox "([^"]*)?" is( not)* checked$/
|
|
354
|
+
*
|
|
355
|
+
*/
|
|
356
|
+
Then(/^the checkbox "([^"]*)?" is( not)* checked$/, function (checkbox, negativeCase) {
|
|
357
|
+
return browser.assert.smartCheckboxChecked(checkbox, negativeCase);
|
|
358
|
+
});
|
|
Binary file
|
package/webship-init.js
CHANGED
|
@@ -9,13 +9,13 @@ var projectPath = '';
|
|
|
9
9
|
const currentPath = process.argv[1].split("node_modules");
|
|
10
10
|
basePath = currentPath[0].substring(0, currentPath[0].lastIndexOf("/")) + '/';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
if (currentPath.length > 1) {
|
|
13
|
+
projectPath = basePath + "node_modules/webship-js/";
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
projectPath = basePath;
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* -----------------------------------------------------
|
|
@@ -36,16 +36,16 @@ parser.add_argument('-ci', '--continuous_integration',
|
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
parser.add_argument('-b', '--browser',
|
|
39
|
-
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
39
|
+
{
|
|
40
|
+
help: 'Add your Browser (chrome, firefox), By default: -b chrome',
|
|
41
|
+
default: 'chrome',
|
|
42
|
+
});
|
|
43
43
|
|
|
44
44
|
parser.add_argument('-os', '--operating_system',
|
|
45
|
-
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
45
|
+
{
|
|
46
|
+
help: 'Add your Operating System (linux, mac, windows), By default: -os linux',
|
|
47
|
+
default: 'linux',
|
|
48
|
+
});
|
|
49
49
|
|
|
50
50
|
var argsParse = parser.parse_args();
|
|
51
51
|
|
package/lib/get-element.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
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
|
-
};
|