webship-js 1.0.22 → 1.0.24
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 +8 -5
- package/.github/workflows/github-actions.yml +26 -7
- package/.gitlab-ci.yml +23 -35
- package/CNAME +1 -0
- package/README.md +4 -7
- package/assets/config_templates/circleci-linux-chrome.conf.js +8 -3
- package/bitbucket-pipelines.yml +1 -1
- package/examples/test--then--i-should--not--see-text-in-element.html +1 -1
- package/examples/test--then--i-should--see-text-in-element.html +48 -0
- package/examples/test--when--i-check-uncheck-checkbox.html +5 -3
- package/examples/test-acceptable-url-path.html +11 -0
- package/generate-reports.js +1 -1
- package/lib/custom-assertions/{smartCheckboxChecked.js → checkboxChecked.js} +43 -10
- package/lib/custom-assertions/{smartElementContainsCss.js → elementContainsCss.js} +42 -10
- package/lib/custom-assertions/{smartElementContains.js → elementContainsText.js} +42 -10
- package/lib/custom-assertions/responseStatus.js +13 -0
- package/lib/custom-assertions/shouldVisible.js +8 -0
- package/lib/custom-assertions/textMatching.js +34 -2
- package/lib/custom-commands/checkItem.js +44 -0
- package/lib/custom-commands/{smartUploadFile.js → fileUpload.js} +0 -1
- package/lib/custom-commands/press.js +3 -0
- package/lib/custom-commands/uncheckItem.js +44 -0
- package/lib/custom-commands/wait.js +12 -0
- package/nightwatch.conf.js +6 -2
- package/package.json +14 -14
- package/tests/features/test--given--i-am-on-homepage.feature +9 -5
- package/tests/features/test--then--i-should--not--see-text-in-element.feature +8 -8
- package/tests/features/test--then--i-should--see-text-matching-pattern-in-element.feature +0 -5
- package/tests/features/test--then--i-should--see-text-matching-pattern.feature +0 -0
- package/tests/features/test--then--i-should-be-on-page.feature +1 -1
- package/tests/features/test--then--the-checkbox-is-checked.feature +9 -9
- package/tests/features/test--then--the-checkbox-should-be-checked.feature +3 -3
- package/tests/features/test--then--the-element-should_not-contain-cssproperty.feature +2 -2
- package/tests/features/test--then--the-field-should-contain-value.feature +4 -4
- package/tests/features/test--then--the-response-status-code-should-be.feature +4 -4
- package/tests/features/test--then--the-url-should-match.feature +7 -0
- package/tests/features/test--when--i-attach-file-to-feild.feature +5 -5
- package/tests/features/test--when--i-check-checkbox.feature +13 -9
- package/tests/features/test--when--i-click-link.feature +2 -2
- package/tests/features/test--when--i-fill-in.feature +8 -8
- package/tests/features/test--when--i-go-to-homepage.feature +10 -0
- package/tests/features/test--when--i-move-forward-backward-one-page.feature +2 -2
- package/tests/features/test--when--i-select-option-from-dropdownlist.feature +1 -1
- package/tests/step-definitions/webship.js +399 -179
- package/lib/custom-commands/smartCheckItem.js +0 -39
- package/lib/custom-commands/smartPressButton.js +0 -12
- package/lib/custom-commands/smartUncheckItem.js +0 -39
- package/tests/features/test--when--i-uncheck-checkbox.feature +0 -18
- /package/lib/custom-commands/{smartClickLink.js → clickLink.js} +0 -0
- /package/lib/custom-commands/{smartFillTextInput.js → fillTextInput.js} +0 -0
- /package/lib/custom-commands/{smartSelectOption.js → selectOption.js} +0 -0
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
const {
|
|
2
|
-
|
|
3
|
-
} = require('@cucumber/cucumber');
|
|
4
|
-
const {
|
|
5
|
-
When,
|
|
6
|
-
Before
|
|
7
|
-
} = require('@cucumber/cucumber');
|
|
8
|
-
const {
|
|
9
|
-
Then
|
|
10
|
-
} = require('@cucumber/cucumber');
|
|
1
|
+
const { Given} = require('@cucumber/cucumber');
|
|
2
|
+
const { When, Before} = require('@cucumber/cucumber');
|
|
3
|
+
const { Then} = require('@cucumber/cucumber');
|
|
11
4
|
|
|
12
5
|
const request = require('request');
|
|
13
6
|
|
|
14
7
|
/**
|
|
15
8
|
* Opens homepage.
|
|
16
9
|
* Example: Given I am on homepage
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
Given(/^(I am|we are) on homepage$/, function (pronoundCase) {
|
|
13
|
+
return browser.url(browser.launch_url);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Opens homepage.
|
|
17
18
|
* Example: Given I am on the homepage
|
|
18
19
|
*
|
|
19
|
-
* @Given /^I am on( the)* homepage$/
|
|
20
20
|
*/
|
|
21
|
-
Given(/^I am on
|
|
21
|
+
Given(/^(I am|we are) on the homepage$/, function (pronoundCase) {
|
|
22
22
|
return browser.url(browser.launch_url);
|
|
23
23
|
});
|
|
24
24
|
|
|
@@ -26,20 +26,28 @@ Given(/^I am on( the)* homepage$/, function (url) {
|
|
|
26
26
|
* Open specific page
|
|
27
27
|
* Example: Given I am on "about-us.html"
|
|
28
28
|
*
|
|
29
|
-
* @Given /^I am on "([^"]*)?"$/
|
|
30
29
|
*/
|
|
31
|
-
Given(/^I am on "([^"]*)?"$/, function (url) {
|
|
30
|
+
Given(/^(I am|we are) on "([^"]*)?"$/, function (pronoundCase, url) {
|
|
32
31
|
return browser.url(browser.launch_url + url);
|
|
33
32
|
});
|
|
34
33
|
|
|
35
34
|
/**
|
|
36
35
|
* Go to homepage
|
|
37
|
-
* Example: When I go to
|
|
36
|
+
* Example: When I go to homepage
|
|
38
37
|
* Example: And I go to "/"
|
|
39
38
|
*
|
|
40
|
-
* @When /^I go to( the)* homepage$/
|
|
41
39
|
*/
|
|
42
|
-
When(/^I go to
|
|
40
|
+
When(/^(I|we)* go to homepage$/, function (pronoundCase) {
|
|
41
|
+
return browser.url(browser.launch_url);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Go to homepage
|
|
46
|
+
* Example: When I go to the homepage
|
|
47
|
+
* Example: And I go to the "/"
|
|
48
|
+
*
|
|
49
|
+
*/
|
|
50
|
+
When(/^(I|we)* go to the homepage$/, function (pronoundCase) {
|
|
43
51
|
return browser.url(browser.launch_url);
|
|
44
52
|
});
|
|
45
53
|
|
|
@@ -47,9 +55,8 @@ When(/^I go to( the)* homepage$/, function () {
|
|
|
47
55
|
* Go to specific page
|
|
48
56
|
* Example: When I go to "contact-us.html"
|
|
49
57
|
*
|
|
50
|
-
* @When /^I go to "([^"]*)?"$/
|
|
51
58
|
*/
|
|
52
|
-
When(/^I go to "([^"]*)?"$/, function (url) {
|
|
59
|
+
When(/^(I|we)* go to "([^"]*)?"$/, function (pronoundCase, url) {
|
|
53
60
|
return browser.url(browser.launch_url + url);
|
|
54
61
|
});
|
|
55
62
|
|
|
@@ -58,59 +65,73 @@ When(/^I go to "([^"]*)?"$/, function (url) {
|
|
|
58
65
|
*
|
|
59
66
|
* Example:
|
|
60
67
|
* - Then I should see "Welcome"
|
|
61
|
-
* - Then I should not see "Access denied"
|
|
62
68
|
*
|
|
63
|
-
* @Then /^I should( not)* see "([^"]*)?"$/
|
|
64
69
|
*/
|
|
65
|
-
Then(/^I should
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
70
|
+
Then(/^(I|we)* should see "([^"]*)?"$/, function (pronoundCase, expectedText) {
|
|
71
|
+
return this.shouldSee = function (browser) {
|
|
72
|
+
browser.assert.textContains("html", expectedText);
|
|
73
|
+
};
|
|
74
|
+
});
|
|
69
75
|
|
|
70
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Asserting a text not in the page.
|
|
78
|
+
*
|
|
79
|
+
* Example:
|
|
80
|
+
* - Then I should not see "Access denied"
|
|
81
|
+
*
|
|
82
|
+
*/
|
|
83
|
+
Then(/^(I|we)* should not see "([^"]*)?"$/, function (pronoundCase, expectedText) {
|
|
84
|
+
return this.shouldSee = function (browser) {
|
|
85
|
+
browser.assert.not.textContains("html", expectedText);
|
|
86
|
+
};
|
|
71
87
|
});
|
|
72
88
|
|
|
73
89
|
/**
|
|
74
|
-
* Moves forward one page in history
|
|
90
|
+
* Moves forward one page in browser history
|
|
75
91
|
* Example: When I move forward one page
|
|
76
92
|
*
|
|
77
|
-
* @When /^I move forward one page$/
|
|
78
93
|
*/
|
|
79
|
-
When(/^I move forward one page$/, function () {
|
|
94
|
+
When(/^(I|we)* move forward one page$/, function (pronoundCase) {
|
|
80
95
|
return browser.forward();
|
|
81
96
|
});
|
|
82
97
|
|
|
83
98
|
/**
|
|
84
|
-
* Moves backward one page in history
|
|
99
|
+
* Moves backward one page in browser history
|
|
85
100
|
* Example: When I move backward one page
|
|
86
101
|
*
|
|
87
|
-
* @When /^I move backward one page$/
|
|
88
102
|
*/
|
|
89
|
-
When(/^I move backward one page$/, function () {
|
|
103
|
+
When(/^(I|we)* move backward one page$/, function (pronoundCase) {
|
|
90
104
|
return browser.back();
|
|
91
105
|
});
|
|
92
106
|
|
|
93
107
|
/**
|
|
94
|
-
* Presses button with specified
|
|
108
|
+
* Presses button with specified element
|
|
95
109
|
* Example: When I press "Log In"
|
|
96
110
|
* Example: And I press "Log In"
|
|
97
111
|
*
|
|
98
|
-
* @When /^I press "([^"]*)?"$/
|
|
99
112
|
*/
|
|
100
|
-
When(/^I press "([^"]*)?"$/, function (
|
|
101
|
-
return browser.click(
|
|
102
|
-
// return browser.smartPressButton(elementValue);
|
|
113
|
+
When(/^(I|we)* press "([^"]*)?"$/, function (pronoundCase, element) {
|
|
114
|
+
return browser.click('[value="' + element + '"]');
|
|
103
115
|
});
|
|
104
116
|
|
|
105
117
|
/**
|
|
106
|
-
* Clicks link with specified
|
|
118
|
+
* Clicks link with specified element
|
|
107
119
|
* Example: When I click "Contact Us"
|
|
108
120
|
* Example: And I click "aboutUs"
|
|
109
121
|
*
|
|
110
|
-
* @When /^I click "([^"]*)?"$/
|
|
111
122
|
*/
|
|
112
|
-
When(/^I click "([^"]*)?"$/, function (item) {
|
|
113
|
-
browser.
|
|
123
|
+
When(/^(I|we)* click "([^"]*)?"$/, function (pronoundCase, item) {
|
|
124
|
+
return browser.click(item);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Reloads current page
|
|
129
|
+
* Example: When I reload page
|
|
130
|
+
* Example: And I reload page
|
|
131
|
+
*
|
|
132
|
+
*/
|
|
133
|
+
When(/^(I|we)* reload page$/, function (pronoundCase) {
|
|
134
|
+
return browser.refresh(browser.getCurrentUrl());
|
|
114
135
|
});
|
|
115
136
|
|
|
116
137
|
/**
|
|
@@ -118,40 +139,37 @@ When(/^I click "([^"]*)?"$/, function (item) {
|
|
|
118
139
|
* Example: When I reload the page
|
|
119
140
|
* Example: And I reload the page
|
|
120
141
|
*
|
|
121
|
-
* @When /^I reload( the)* page$/
|
|
122
142
|
*/
|
|
123
|
-
When(/^I reload
|
|
143
|
+
When(/^(I|we)* reload the page$/, function (pronoundCase) {
|
|
124
144
|
return browser.refresh(browser.getCurrentUrl());
|
|
125
145
|
});
|
|
126
146
|
|
|
147
|
+
|
|
127
148
|
/**
|
|
128
|
-
* Define the step of filling values in the form field specified
|
|
149
|
+
* Define the step of filling values in the form field specified element.
|
|
129
150
|
* Example: When I fill in "Username" with "John Smith"
|
|
130
151
|
*
|
|
131
|
-
* @When /^I fill in "([^"]*)?" with "([^"]*)?"$/
|
|
132
152
|
*/
|
|
133
|
-
When(/^I fill in "([^"]*)?" with "([^"]*)?"$/, function (field, value) {
|
|
134
|
-
browser.
|
|
153
|
+
When(/^(I|we)* fill in "([^"]*)?" with "([^"]*)?"$/, function (pronoundCase, field, value) {
|
|
154
|
+
browser.setValue(field, value);
|
|
135
155
|
});
|
|
136
156
|
|
|
137
157
|
/**
|
|
138
|
-
* Fills in form field with specified
|
|
158
|
+
* Fills in form field with specified element
|
|
139
159
|
* Example: When I fill in "username" with:
|
|
140
160
|
*
|
|
141
|
-
* @When /^I fill in "([^"]*)?" with:$/
|
|
142
161
|
*/
|
|
143
|
-
When(/^I fill in "([^"]*)?" with:$/, function (field) {
|
|
144
|
-
browser.
|
|
162
|
+
When(/^(I|we)* fill in "([^"]*)?" with:$/, function (pronoundCase, field) {
|
|
163
|
+
browser.setValue(field, '');
|
|
145
164
|
});
|
|
146
165
|
|
|
147
166
|
/**
|
|
148
|
-
* Fills in form field with specified
|
|
167
|
+
* Fills in form field with specified element
|
|
149
168
|
* Example: And I fill in "webshipco" for "username"
|
|
150
169
|
*
|
|
151
|
-
* @When /^I fill in "([^"]*)?" for "([^"]*)?"$/
|
|
152
170
|
*/
|
|
153
|
-
When(/^I fill in "([^"]*)?" for "([^"]*)?"$/, function (value, field) {
|
|
154
|
-
browser.
|
|
171
|
+
When(/^(I|we)* fill in "([^"]*)?" for "([^"]*)?"$/, function (pronoundCase, value, field) {
|
|
172
|
+
browser.setValue(field, value);
|
|
155
173
|
});
|
|
156
174
|
|
|
157
175
|
/**
|
|
@@ -163,236 +181,395 @@ When(/^I fill in "([^"]*)?" for "([^"]*)?"$/, function (value, field) {
|
|
|
163
181
|
* | username | webshipco |
|
|
164
182
|
* | password | 1234 |
|
|
165
183
|
*
|
|
166
|
-
* @When /^I fill in the following:$/
|
|
167
184
|
*/
|
|
168
|
-
When(/^I fill in the following:$/, function (table) {
|
|
185
|
+
When(/^(I|we)* fill in the following:$/, function (pronoundCase, table) {
|
|
169
186
|
|
|
170
|
-
browser.
|
|
187
|
+
browser.setValue(table.rawTable[0][0], table.rawTable[0][1]);
|
|
171
188
|
table.rows().forEach(row => {
|
|
172
|
-
browser.
|
|
189
|
+
browser.setValue(row[0], row[1]);
|
|
190
|
+
// browser.fillTextInput(row[0], row[1]);
|
|
173
191
|
});
|
|
174
192
|
});
|
|
175
193
|
|
|
176
194
|
/**
|
|
177
|
-
* Selects option in select field
|
|
195
|
+
* Selects option in select field
|
|
178
196
|
* Example: When I select "mercedes" from "Cars"
|
|
179
197
|
*
|
|
180
|
-
* @When /^I select "([^"]*)?" from "([^"]*)?"$/
|
|
181
198
|
*/
|
|
182
|
-
When(/^I select "([^"]*)?" from "([^"]*)?"$/, function (option, dropdownlist) {
|
|
183
|
-
|
|
199
|
+
When(/^(I|we)* select "([^"]*)?" from "([^"]*)?"$/, function (pronoundCase, option, dropdownlist) {
|
|
200
|
+
|
|
201
|
+
return browser.click('select' + dropdownlist + ' option[value=' + option + ']');
|
|
184
202
|
});
|
|
185
203
|
|
|
186
204
|
/**
|
|
187
|
-
* Checks checkbox specified
|
|
205
|
+
* Checks checkbox specified
|
|
188
206
|
* Example: When I check "Remember me"
|
|
189
207
|
*
|
|
190
|
-
* @When /^I check "([^"]*)?"$/
|
|
191
208
|
*/
|
|
192
|
-
When(/^I check "([^"]*)?"$/, function (item) {
|
|
193
|
-
browser.
|
|
209
|
+
When(/^(I|we)* check "([^"]*)?"$/, function (pronoundCase, item) {
|
|
210
|
+
browser.isSelected(item, function (result) {
|
|
211
|
+
if (!result.value) {
|
|
212
|
+
this.click(item);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
194
215
|
});
|
|
195
216
|
|
|
196
217
|
/**
|
|
197
|
-
* Unchecks checkbox specified
|
|
218
|
+
* Unchecks checkbox specified
|
|
198
219
|
* Example: When I uncheck "Remember me"
|
|
199
220
|
*
|
|
200
|
-
* @When /^I uncheck "([^"]*)?"$/
|
|
201
221
|
*/
|
|
202
|
-
When(/^I uncheck "([^"]*)?"$/, function (item) {
|
|
203
|
-
browser.
|
|
222
|
+
When(/^(I|we)* uncheck "([^"]*)?"$/, function (pronoundCase, item) {
|
|
223
|
+
browser.isSelected(item, function (result) {
|
|
224
|
+
if (result.value) {
|
|
225
|
+
this.click(item);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Verify, that current page is the homepage
|
|
232
|
+
* Example: Then I should be on homepage
|
|
233
|
+
*
|
|
234
|
+
*/
|
|
235
|
+
Then(/^(I|we)* should be on homepage$/, function (pronoundCase) {
|
|
236
|
+
return browser.assert.urlMatches(browser.launch_url);
|
|
204
237
|
});
|
|
205
238
|
|
|
206
239
|
/**
|
|
207
240
|
* Verify, that current page is the homepage
|
|
208
241
|
* Example: Then I should be on the homepage
|
|
209
242
|
*
|
|
210
|
-
* @Then /^I should be on( the)* homepage$/
|
|
211
243
|
*/
|
|
212
|
-
Then(/^I should be on
|
|
213
|
-
return browser.assert.
|
|
244
|
+
Then(/^(I|we)* should be on the homepage$/, function (pronoundCase) {
|
|
245
|
+
return browser.assert.urlMatches(browser.launch_url);
|
|
214
246
|
});
|
|
215
247
|
|
|
216
248
|
/**
|
|
217
|
-
* Verify, that current page
|
|
249
|
+
* Verify, that current page is the homepage
|
|
250
|
+
* Example: Then I should not be on homepage
|
|
251
|
+
*
|
|
252
|
+
*/
|
|
253
|
+
Then(/^(I|we)* should not be on homepage$/, function (pronoundCase) {
|
|
254
|
+
return browser.assert.not.urlMatches(browser.launch_url);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Verify, that current page is the homepage
|
|
259
|
+
* Example: Then I should not be on the homepage
|
|
260
|
+
*
|
|
261
|
+
*/
|
|
262
|
+
Then(/^(I|we)* should not be on the homepage$/, function (pronoundCase) {
|
|
263
|
+
return browser.assert.not.urlMatches(browser.launch_url);
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Verify, that current page path is equal to specified path
|
|
218
268
|
* Example: Then I should be on "/"
|
|
219
269
|
* Example: And I should be on "/user/login"
|
|
220
270
|
* Example: And I should be on "http://google.com"
|
|
221
271
|
*
|
|
222
|
-
* @Then /^I should be on "([^"]*)?"$/
|
|
223
272
|
*/
|
|
224
|
-
Then(/^I should be on "([^"]*)?"$/, function (url) {
|
|
273
|
+
Then(/^(I|we)* should be on "([^"]*)?"$/, function (pronoundCase, url) {
|
|
225
274
|
return browser.assert.urlContains(url);
|
|
226
275
|
});
|
|
227
276
|
|
|
228
277
|
/**
|
|
229
|
-
* Checks, that HTML response contains specific text
|
|
278
|
+
* Checks, that HTML response contains specific text
|
|
230
279
|
* Example: Then the response should contain "Welcome visitor, How can I help you?"
|
|
280
|
+
*
|
|
281
|
+
*/
|
|
282
|
+
Then(/^the response should contain "([^"]*)?"$/, function (expectedText) {
|
|
283
|
+
return this.shouldSee = function (browser) {
|
|
284
|
+
browser.assert.textContains("html", expectedText);
|
|
285
|
+
};
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Checks, that HTML response contains specific text
|
|
231
290
|
* Example: Then the response should not contain "Error: Ambiguous messages that are unclear"
|
|
232
291
|
*
|
|
233
|
-
* @Then /^the response should contain "([^"]*)?"$/
|
|
234
292
|
*/
|
|
235
|
-
Then(/^the response should
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
293
|
+
Then(/^the response should not contain "([^"]*)?"$/, function (expectedText) {
|
|
294
|
+
return this.shouldSee = function (browser) {
|
|
295
|
+
browser.assert.not.textContains("html", expectedText);
|
|
296
|
+
};
|
|
297
|
+
});
|
|
298
|
+
|
|
239
299
|
|
|
240
|
-
|
|
300
|
+
/**
|
|
301
|
+
* Assert, that element contains a specific text value
|
|
302
|
+
* Example: Then I should see "John Smith" in the "#username" element
|
|
303
|
+
*
|
|
304
|
+
*/
|
|
305
|
+
Then(/^(I|we)* should see "([^"]*)?" in the "([^"]*)?" element$/, function (pronoundCase, expectedText, element) {
|
|
306
|
+
return this.shouldSee = function (browser) {
|
|
307
|
+
browser.assert.textContains(element, expectedText);
|
|
308
|
+
};
|
|
241
309
|
});
|
|
242
310
|
|
|
243
311
|
/**
|
|
244
|
-
* Assert, that element contains a specific text value
|
|
245
|
-
* Example: Then I should see "
|
|
246
|
-
* Example: Then I should see "Joe Smith" in the "Username" element
|
|
312
|
+
* Assert, that element contains a specific text value
|
|
313
|
+
* Example: Then I should not see "Joe Smith" in the "#username" element
|
|
247
314
|
*
|
|
248
|
-
* @Then /^I should( not)* see "([^"]*)?" in the "([^"]*)?" element$/
|
|
249
315
|
*/
|
|
250
|
-
Then(/^I should
|
|
251
|
-
|
|
316
|
+
Then(/^(I|we)* should not see "([^"]*)?" in the "([^"]*)?" element$/, function (pronoundCase, expectedText, element) {
|
|
317
|
+
|
|
318
|
+
return this.shouldSee = function (browser) {
|
|
319
|
+
browser.assert.not.textContains(element, expectedText);
|
|
320
|
+
};
|
|
252
321
|
});
|
|
253
322
|
|
|
254
323
|
/**
|
|
255
|
-
* Assert, that element exists on page
|
|
324
|
+
* Assert, that element exists on current page
|
|
256
325
|
* Example: Then I should see a "body" element
|
|
257
|
-
* Example: Then I should see an "Email" element
|
|
258
|
-
* Example: Then I should not see a "Username" element
|
|
259
|
-
* Example: Then I should not see an "img" element
|
|
260
326
|
*
|
|
261
|
-
* @Then /^I should( not)* see a(n)* "([^"]*)?" element$/
|
|
262
327
|
*/
|
|
263
|
-
Then(/^I should
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
328
|
+
Then(/^(I|we)* should see a "([^"]*)?" element$/, function (pronoundCase, element) {
|
|
329
|
+
return browser.verify.visible(element);
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Assert, that element exists on current page
|
|
334
|
+
* Example: Then I should see an "#email" element
|
|
335
|
+
*
|
|
336
|
+
*/
|
|
337
|
+
Then(/^(I|we)* should see an "([^"]*)?" element$/, function (pronoundCase, element) {
|
|
267
338
|
return browser.verify.visible(element);
|
|
268
339
|
});
|
|
269
340
|
|
|
270
341
|
/**
|
|
271
|
-
* Assert, that element
|
|
342
|
+
* Assert, that element not exists on current page
|
|
343
|
+
* Example: Then I should not see a "#username" element
|
|
344
|
+
*
|
|
345
|
+
*/
|
|
346
|
+
Then(/^(I|we)* should not see a "([^"]*)?" element$/, function (pronoundCase, element) {
|
|
347
|
+
return browser.verify.not.visible(element);
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Assert, that element not exists on current page
|
|
352
|
+
* Example: Then I should not see a "Username" element
|
|
353
|
+
*
|
|
354
|
+
*/
|
|
355
|
+
Then(/^(I|we)* should not see a "([^"]*)?" element$/, function (pronoundCase, element) {
|
|
356
|
+
return browser.verify.not.visible(element);
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Assert, that element exists on current page
|
|
361
|
+
* Example: Then I should not see an "#img" element
|
|
362
|
+
*
|
|
363
|
+
*/
|
|
364
|
+
Then(/^(I|we)* should not see an "([^"]*)?" element$/, function (pronoundCase, element) {
|
|
365
|
+
return browser.verify.not.visible(element);
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Assert, that element contains a specific CSS style
|
|
272
370
|
* Example: Then the "body" element should contain "color:white;"
|
|
273
371
|
*
|
|
274
|
-
* @Then /^the "([^"]*)?" element should( not)* contain "([^"]*)?"$/
|
|
275
372
|
*/
|
|
276
|
-
Then(/^the "([^"]*)?" element should
|
|
277
|
-
|
|
373
|
+
Then(/^the "([^"]*)?" element should contain "([^"]*)?"$/, function (element, elementCss) {
|
|
374
|
+
|
|
375
|
+
elementCss = elementCss.replace(";", '');
|
|
376
|
+
const cssPropertyArr = elementCss.split(":");
|
|
377
|
+
|
|
378
|
+
const cssProperty = cssPropertyArr[0].trim();
|
|
379
|
+
const propertyVal = cssPropertyArr[1].trim();
|
|
380
|
+
|
|
381
|
+
this.checkCss = function (browser) {
|
|
382
|
+
browser.assert.cssProperty(element, cssProperty, propertyVal);
|
|
383
|
+
};
|
|
278
384
|
});
|
|
279
385
|
|
|
280
386
|
/**
|
|
281
|
-
*
|
|
387
|
+
* Assert, that element contains a specific CSS style
|
|
388
|
+
* Example: Then the "body" element should not contain "color:white;"
|
|
389
|
+
*
|
|
390
|
+
*/
|
|
391
|
+
Then(/^the "([^"]*)?" element should not contain "([^"]*)?"$/, function (element, elementCss) {
|
|
392
|
+
|
|
393
|
+
elementCss = elementCss.replace(";", '');
|
|
394
|
+
const cssPropertyArr = elementCss.split(":");
|
|
395
|
+
|
|
396
|
+
const cssProperty = cssPropertyArr[0].trim();
|
|
397
|
+
const propertyVal = cssPropertyArr[1].trim();
|
|
398
|
+
|
|
399
|
+
this.checkCss = function (browser) {
|
|
400
|
+
browser.assert.not.cssProperty(element, cssProperty, propertyVal);
|
|
401
|
+
};
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Attaches file to field
|
|
282
406
|
* Example: When I attach the file "profileIcon.jpg" to "profileIconUpload"
|
|
283
407
|
*
|
|
284
|
-
* @When /^I attach the file "([^"]*)?" to "([^"]*)?"$/
|
|
285
408
|
*/
|
|
286
|
-
When(/^I attach the file "([^"]*)?" to "([^"]*)?"$/, function (fileUrl, element) {
|
|
287
|
-
browser.
|
|
409
|
+
When(/^(I|we)* attach the file "([^"]*)?" to "([^"]*)?"$/, function (pronoundCase, fileUrl, element) {
|
|
410
|
+
// browser.setValue(element, require('path').resolve(__dirname + fileUrl));
|
|
288
411
|
});
|
|
289
412
|
|
|
290
413
|
/**
|
|
291
|
-
* Assert, that
|
|
292
|
-
* Example: Then the "username" field should contain "John Smith"
|
|
414
|
+
* Assert, that field contain a specific text
|
|
415
|
+
* Example: Then the "#username" field should contain "John Smith"
|
|
293
416
|
*
|
|
294
|
-
* @Then /^the "([^"]*)?" field should( not)* contain "([^"]*)?"$/
|
|
295
417
|
*/
|
|
296
|
-
Then(/^the "([^"]*)?" field should
|
|
297
|
-
|
|
418
|
+
Then(/^the "([^"]*)?" field should contain "([^"]*)?"$/, function (field, expectedText) {
|
|
419
|
+
|
|
420
|
+
return this.shouldSee = function (browser) {
|
|
421
|
+
browser.assert.textContains(field, expectedText);
|
|
422
|
+
};
|
|
298
423
|
});
|
|
299
424
|
|
|
300
425
|
/**
|
|
301
|
-
* Assert, that
|
|
302
|
-
* Example: Then the "
|
|
426
|
+
* Assert, that field does not contain a specific text
|
|
427
|
+
* Example: Then the "#username" field should not contain "John Smith"
|
|
303
428
|
*
|
|
304
|
-
|
|
429
|
+
*/
|
|
430
|
+
Then(/^the "([^"]*)?" field should not contain "([^"]*)?"$/, function (field, expectedText) {
|
|
431
|
+
|
|
432
|
+
return this.shouldSee = function (browser) {
|
|
433
|
+
browser.assert.not.textContains(field, expectedText);
|
|
434
|
+
};
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Assert, that checkbox with specified element is should be checked
|
|
439
|
+
* Example: Then the "#PrivacyPolicy" checkbox should be checked
|
|
305
440
|
*
|
|
306
441
|
*/
|
|
307
|
-
Then(/^the "([^"]*)?" checkbox should
|
|
308
|
-
return browser.
|
|
442
|
+
Then(/^the "([^"]*)?" checkbox should be checked$/, function (checkbox) {
|
|
443
|
+
return browser.expect.element(checkbox).to.be.selected;
|
|
309
444
|
});
|
|
310
445
|
|
|
311
446
|
/**
|
|
312
|
-
*
|
|
313
|
-
* Example: Then the "
|
|
314
|
-
*
|
|
315
|
-
* @Then /^the "([^"]*)?" checkbox is( not)* checked$/
|
|
447
|
+
* Assert, that checkbox with specified element is should not be checked
|
|
448
|
+
* Example: Then the "#PrivacyPolicy" checkbox should not be checked
|
|
316
449
|
*
|
|
317
450
|
*/
|
|
318
|
-
Then(/^the "([^"]*)?" checkbox
|
|
319
|
-
return browser.
|
|
451
|
+
Then(/^the "([^"]*)?" checkbox should not be checked$/, function (checkbox) {
|
|
452
|
+
return browser.expect.element(checkbox).to.not.be.selected;
|
|
320
453
|
});
|
|
321
454
|
|
|
322
455
|
/**
|
|
323
|
-
*
|
|
324
|
-
* Example: Then the
|
|
325
|
-
* Example: Then the checkbox "PrivacyPolicy" should not be checked
|
|
456
|
+
* Check, whether the checkbox specified is checked.
|
|
457
|
+
* Example: Then the "#rememberMe" checkbox is checked
|
|
326
458
|
*
|
|
327
|
-
* @Then /^the checkbox "([^"]*)?" should(not)* be checked$/
|
|
328
|
-
*
|
|
329
459
|
*/
|
|
330
|
-
Then(/^the
|
|
331
|
-
return browser.
|
|
460
|
+
Then(/^the "([^"]*)?" checkbox is checked$/, function (checkbox) {
|
|
461
|
+
return browser.expect.element(checkbox).to.be.selected;
|
|
332
462
|
});
|
|
333
463
|
|
|
334
464
|
/**
|
|
335
|
-
*
|
|
336
|
-
* Example: Then the
|
|
337
|
-
*
|
|
465
|
+
* Check, whether the checkbox specified is not checked.
|
|
466
|
+
* Example: Then the "#rememberMe" checkbox is not checked
|
|
467
|
+
*
|
|
468
|
+
*/
|
|
469
|
+
Then(/^the "([^"]*)?" checkbox is not checked$/, function (checkbox) {
|
|
470
|
+
return browser.expect.element(checkbox).to.not.be.selected;
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Assert, that checkbox with specified element should be checked
|
|
475
|
+
* Example: Then the checkbox "#PrivacyPolicy" should be checked
|
|
476
|
+
*
|
|
477
|
+
*/
|
|
478
|
+
Then(/^the checkbox "([^"]*)?" should be checked$/, function (checkbox) {
|
|
479
|
+
return browser.expect.element(checkbox).to.be.selected;
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Assert, that checkbox with specified element should not be checked
|
|
484
|
+
* Example: Then the checkbox "#PrivacyPolicy" should not be checked
|
|
485
|
+
*
|
|
486
|
+
*/
|
|
487
|
+
Then(/^the checkbox "([^"]*)?" should not be checked$/, function (checkbox) {
|
|
488
|
+
return browser.expect.element(checkbox).to.not.be.selected;
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Assert, that checkbox with specified element is checked
|
|
493
|
+
* Example: Then the checkbox "#rememberMe" is checked
|
|
338
494
|
*
|
|
339
|
-
* @Then /^the checkbox "([^"]*)?" is( not)* checked$/
|
|
340
|
-
*
|
|
341
495
|
*/
|
|
342
|
-
Then(/^the checkbox "([^"]*)?" is
|
|
343
|
-
return browser.
|
|
496
|
+
Then(/^the checkbox "([^"]*)?" is checked$/, function (checkbox) {
|
|
497
|
+
return browser.expect.element(checkbox).to.be.selected;
|
|
344
498
|
});
|
|
345
499
|
|
|
346
500
|
/**
|
|
347
|
-
*
|
|
501
|
+
* Assert, that checkbox with specified element is not checked
|
|
502
|
+
* Example: Then the checkbox "#rememberMe" is not checked
|
|
503
|
+
*
|
|
504
|
+
*/
|
|
505
|
+
Then(/^the checkbox "([^"]*)?" is not checked$/, function (checkbox) {
|
|
506
|
+
return browser.expect.element(checkbox).to.not.be.selected;
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Wait a specific number of seconds.
|
|
348
511
|
* Example: When I wait 1 second
|
|
349
512
|
* Example: When I wait 5 seconds
|
|
350
|
-
* Example: When I wait max of 6 seconds
|
|
351
513
|
*
|
|
352
|
-
* @When /^I wait( max of)* "([^"]*)?" second(s)*$/
|
|
353
|
-
*
|
|
354
514
|
*/
|
|
355
|
-
When(/^I wait
|
|
515
|
+
When(/^(I|we)* wait (\d*) second(s)*$/, function (pronoundCase, number, withS) {
|
|
356
516
|
var waitTime = number * 1000;
|
|
357
|
-
if (maxof) {
|
|
358
|
-
return browser.waitForElementPresent('body', waitTime);
|
|
359
|
-
}
|
|
360
517
|
return browser.pause(waitTime);
|
|
361
518
|
});
|
|
362
519
|
|
|
363
520
|
/**
|
|
364
|
-
* Wait a
|
|
521
|
+
* Wait a max number of seconds until the element present.
|
|
522
|
+
* Example: When I wait max of 6 seconds
|
|
523
|
+
*
|
|
524
|
+
*/
|
|
525
|
+
When(/^(I|we)* wait max of (\d*) second(s)*$/, function (pronoundCase, number, withS) {
|
|
526
|
+
var waitTime = number * 1000;
|
|
527
|
+
return browser.waitForElementPresent('body', waitTime);
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* Wait a specific number of minutes.
|
|
365
532
|
* Example: When I wait 1 minute
|
|
366
533
|
* Example: When I wait 5 minutes
|
|
367
|
-
* Example: When I wait max of 6 minutes
|
|
368
534
|
*
|
|
369
|
-
* @When /^I wait( max of)* "([^"]*)?" minute(s)*$/
|
|
370
|
-
*
|
|
371
535
|
*/
|
|
372
|
-
When(/^I wait
|
|
373
|
-
var waitTime = number *
|
|
374
|
-
if (maxof) {
|
|
375
|
-
return browser.waitForElementPresent('body', waitTime);
|
|
376
|
-
}
|
|
536
|
+
When(/^(I|we)* wait (\d*) minute(s)*$/, function (pronoundCase, number, withS) {
|
|
537
|
+
var waitTime = number * 1000 * 60;
|
|
377
538
|
return browser.pause(waitTime);
|
|
378
539
|
});
|
|
379
540
|
|
|
380
541
|
/**
|
|
381
|
-
*
|
|
382
|
-
* Example:
|
|
383
|
-
* Example: And the response status code should not be 404
|
|
542
|
+
* Wait a max number of minutes until the element present.
|
|
543
|
+
* Example: When I wait max of 6 minutes
|
|
384
544
|
*
|
|
385
|
-
* @Then /^the response status code should( not)* be (?P<code>\d+)$/
|
|
386
545
|
*/
|
|
387
|
-
|
|
546
|
+
When(/^(I|we)* wait max of (\d*) minute(s)*$/, function (pronoundCase, number, withS) {
|
|
547
|
+
var waitTime = number * 1000 * 60;
|
|
548
|
+
return browser.waitForElementPresent('body', waitTime);
|
|
549
|
+
});
|
|
388
550
|
|
|
389
|
-
|
|
551
|
+
/**
|
|
552
|
+
* Checks, that the current page response status is equal the specified code
|
|
553
|
+
* Example: Then the response status code should be 200
|
|
554
|
+
*
|
|
555
|
+
*/
|
|
556
|
+
Then(/^the response status code should be (\d+)$/, function (expectedStatusCode) {
|
|
557
|
+
return browser.url(function (currentURL) {
|
|
390
558
|
request(currentURL.value, (error, response, body) => {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
559
|
+
browser.assert.equal(response.statusCode, expectedStatusCode);
|
|
560
|
+
});
|
|
561
|
+
});
|
|
562
|
+
});
|
|
395
563
|
|
|
564
|
+
/**
|
|
565
|
+
* Checks, that the current page response status is not equal the specified code
|
|
566
|
+
* Example: And the response status code should not be 404
|
|
567
|
+
*
|
|
568
|
+
*/
|
|
569
|
+
Then(/^the response status code should not be (\d+)$/, function ( expectedStatusCode) {
|
|
570
|
+
return browser.url(function (currentURL) {
|
|
571
|
+
request(currentURL.value, (error, response, body) => {
|
|
572
|
+
browser.assert.not.equal(response.statusCode, expectedStatusCode);
|
|
396
573
|
});
|
|
397
574
|
});
|
|
398
575
|
});
|
|
@@ -401,33 +578,76 @@ Then(/^the response status code should( not)* be (\d+)$/, function (negativeCase
|
|
|
401
578
|
* Checks, that page contains text matching specified pattern
|
|
402
579
|
* Example: Then I should see text matching "^T\w+" //pattern of word start with 'T'
|
|
403
580
|
*
|
|
404
|
-
* @Then /^I should see( not)* text matching "([^"]*)?" in the "([^"]*)?" element$/
|
|
405
581
|
*/
|
|
406
|
-
Then(/^I should
|
|
407
|
-
// return browser.assert.smartTextMatching(negativeCase, textPattern);
|
|
582
|
+
Then(/^(I|we)* should see text matching "([^"]*)?"$/, function (pronoundCase, textPattern) {
|
|
408
583
|
browser.elements('css selector', 'body', function (elements) {
|
|
409
584
|
elements.value.forEach(function (elementsObj) {
|
|
410
|
-
if (negativeCase) {
|
|
411
|
-
return browser.assert.not.textMatches(elementsObj, textPattern);
|
|
412
|
-
}
|
|
413
585
|
return browser.assert.textMatches(elementsObj, textPattern);
|
|
414
586
|
});
|
|
415
587
|
});
|
|
416
588
|
});
|
|
417
589
|
|
|
418
590
|
/**
|
|
419
|
-
* Checks, that page contains text matching specified pattern
|
|
420
|
-
* Example: Then I should see text matching "
|
|
591
|
+
* Checks, that page not contains text matching specified pattern
|
|
592
|
+
* Example: Then I should not see text matching "^O\w+" //pattern of word start with 'O'
|
|
421
593
|
*
|
|
422
|
-
* @Then /^I should see( not)* text matching "([^"]*)?" in the "([^"]*)?" element$/
|
|
423
594
|
*/
|
|
424
|
-
Then(/^I should
|
|
425
|
-
browser.elements('css selector',
|
|
595
|
+
Then(/^(I|we)* should not see text matching "([^"]*)?"$/, function (pronoundCase, textPattern) {
|
|
596
|
+
browser.elements('css selector', 'body', function (elements) {
|
|
426
597
|
elements.value.forEach(function (elementsObj) {
|
|
427
|
-
|
|
428
|
-
return browser.assert.not.textMatches(elementsObj, textPattern);
|
|
429
|
-
}
|
|
430
|
-
return browser.assert.textMatches(elementsObj, textPattern);
|
|
598
|
+
return browser.assert.not.textMatches(elementsObj, textPattern);
|
|
431
599
|
});
|
|
432
600
|
});
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* Checks, that page contains text matching specified pattern
|
|
605
|
+
* Example: Then I should see text matching "(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}" in the "#date" element
|
|
606
|
+
* //pattern of DD/MM/YYYY or DD-MM-YYYY
|
|
607
|
+
*
|
|
608
|
+
*/
|
|
609
|
+
Then(/^(I|we)* should see text matching "([^"]*)?" in the "([^"]*)?" element$/, function (pronoundCase, textPattern, element) {
|
|
610
|
+
// return browser.elements('css selector', element, function (elements) {
|
|
611
|
+
// elements.value.forEach(function (elementsObj) {
|
|
612
|
+
return this.shouldSeePattern = function (browser) {
|
|
613
|
+
browser.assert.textMatches(element, textPattern);
|
|
614
|
+
};
|
|
615
|
+
// });
|
|
616
|
+
// });
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* Checks, that page contains text matching specified pattern
|
|
621
|
+
* Example: Then I should not see text matching "(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}" in the "#date" element
|
|
622
|
+
* //pattern of DD/MM/YYYY or DD-MM-YYYY
|
|
623
|
+
*
|
|
624
|
+
*/
|
|
625
|
+
Then(/^(I|we)* should not see text matching "([^"]*)?" in the "([^"]*)?" element$/, function (pronoundCase, textPattern, element) {
|
|
626
|
+
|
|
627
|
+
// return browser.elements('css selector', element, function (elements) {
|
|
628
|
+
// elements.value.forEach(function (elementsObj) {
|
|
629
|
+
return this.shouldSeePattern = function (browser) {
|
|
630
|
+
browser.assert.not.textMatches(element, textPattern);
|
|
631
|
+
};
|
|
632
|
+
// browser.assert.not.textMatches(elementsObj, textPattern);
|
|
633
|
+
// });
|
|
634
|
+
// });
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Checks, that current URL Path matches regular expression
|
|
639
|
+
* Example: Then the url should match "/contact-us.html"
|
|
640
|
+
*
|
|
641
|
+
*/
|
|
642
|
+
Then(/^the url should match "([^"]*)?"$/, function (pattern) {
|
|
643
|
+
return browser.assert.urlMatches(pattern);
|
|
644
|
+
});
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* Checks, that current URL Path matches regular expression
|
|
648
|
+
* Example: Then the url should not match "/contact-us.html"
|
|
649
|
+
*
|
|
650
|
+
*/
|
|
651
|
+
Then(/^the url should not match "([^"]*)?"$/, function (pattern) {
|
|
652
|
+
return browser.assert.not.urlMatches(pattern);
|
|
433
653
|
});
|