webship-js 1.0.23 → 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/.github/workflows/github-actions.yml +25 -9
- 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--see-text-in-element.html +48 -0
- package/examples/test--when--i-check-uncheck-checkbox.html +5 -3
- package/lib/custom-assertions/checkboxChecked.js +33 -0
- package/lib/custom-assertions/elementContainsCss.js +32 -0
- package/lib/custom-assertions/elementContainsText.js +32 -0
- package/lib/custom-assertions/responseStatus.js +1 -1
- package/lib/custom-assertions/shouldVisible.js +1 -1
- package/lib/custom-assertions/textMatching.js +32 -0
- package/lib/custom-commands/checkItem.js +21 -16
- package/lib/custom-commands/uncheckItem.js +21 -16
- package/nightwatch.conf.js +5 -1
- package/package.json +14 -14
- 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--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--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 +381 -102
- package/lib/custom-assertions/backToHomepage.js +0 -15
- package/tests/features/test--when--i-uncheck-checkbox.feature +0 -18
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const {
|
|
3
|
-
const {
|
|
4
|
-
const { endsWith } = require('lodash');
|
|
1
|
+
const { Given} = require('@cucumber/cucumber');
|
|
2
|
+
const { When, Before} = require('@cucumber/cucumber');
|
|
3
|
+
const { Then} = require('@cucumber/cucumber');
|
|
5
4
|
|
|
6
5
|
const request = require('request');
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Opens homepage.
|
|
10
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.
|
|
11
18
|
* Example: Given I am on the homepage
|
|
12
19
|
*
|
|
13
20
|
*/
|
|
14
|
-
Given(/^(I am|we are) on
|
|
21
|
+
Given(/^(I am|we are) on the homepage$/, function (pronoundCase) {
|
|
15
22
|
return browser.url(browser.launch_url);
|
|
16
23
|
});
|
|
17
24
|
|
|
@@ -26,11 +33,21 @@ Given(/^(I am|we are) on "([^"]*)?"$/, function (pronoundCase, url) {
|
|
|
26
33
|
|
|
27
34
|
/**
|
|
28
35
|
* Go to homepage
|
|
29
|
-
* Example: When I go to
|
|
36
|
+
* Example: When I go to homepage
|
|
30
37
|
* Example: And I go to "/"
|
|
31
38
|
*
|
|
32
39
|
*/
|
|
33
|
-
When(/^(I|we)* 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) {
|
|
34
51
|
return browser.url(browser.launch_url);
|
|
35
52
|
});
|
|
36
53
|
|
|
@@ -48,15 +65,29 @@ When(/^(I|we)* go to "([^"]*)?"$/, function (pronoundCase, url) {
|
|
|
48
65
|
*
|
|
49
66
|
* Example:
|
|
50
67
|
* - Then I should see "Welcome"
|
|
68
|
+
*
|
|
69
|
+
*/
|
|
70
|
+
Then(/^(I|we)* should see "([^"]*)?"$/, function (pronoundCase, expectedText) {
|
|
71
|
+
return this.shouldSee = function (browser) {
|
|
72
|
+
browser.assert.textContains("html", expectedText);
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Asserting a text not in the page.
|
|
78
|
+
*
|
|
79
|
+
* Example:
|
|
51
80
|
* - Then I should not see "Access denied"
|
|
52
81
|
*
|
|
53
82
|
*/
|
|
54
|
-
Then(/^(I|we)* should
|
|
55
|
-
return
|
|
83
|
+
Then(/^(I|we)* should not see "([^"]*)?"$/, function (pronoundCase, expectedText) {
|
|
84
|
+
return this.shouldSee = function (browser) {
|
|
85
|
+
browser.assert.not.textContains("html", expectedText);
|
|
86
|
+
};
|
|
56
87
|
});
|
|
57
88
|
|
|
58
89
|
/**
|
|
59
|
-
* Moves forward one page in history
|
|
90
|
+
* Moves forward one page in browser history
|
|
60
91
|
* Example: When I move forward one page
|
|
61
92
|
*
|
|
62
93
|
*/
|
|
@@ -65,7 +96,7 @@ When(/^(I|we)* move forward one page$/, function (pronoundCase) {
|
|
|
65
96
|
});
|
|
66
97
|
|
|
67
98
|
/**
|
|
68
|
-
* Moves backward one page in history
|
|
99
|
+
* Moves backward one page in browser history
|
|
69
100
|
* Example: When I move backward one page
|
|
70
101
|
*
|
|
71
102
|
*/
|
|
@@ -74,23 +105,33 @@ When(/^(I|we)* move backward one page$/, function (pronoundCase) {
|
|
|
74
105
|
});
|
|
75
106
|
|
|
76
107
|
/**
|
|
77
|
-
* Presses button with specified
|
|
108
|
+
* Presses button with specified element
|
|
78
109
|
* Example: When I press "Log In"
|
|
79
110
|
* Example: And I press "Log In"
|
|
80
111
|
*
|
|
81
112
|
*/
|
|
82
|
-
When(/^(I|we)* press "([^"]*)?"$/, function (pronoundCase,
|
|
83
|
-
return browser.
|
|
113
|
+
When(/^(I|we)* press "([^"]*)?"$/, function (pronoundCase, element) {
|
|
114
|
+
return browser.click('[value="' + element + '"]');
|
|
84
115
|
});
|
|
85
116
|
|
|
86
117
|
/**
|
|
87
|
-
* Clicks link with specified
|
|
118
|
+
* Clicks link with specified element
|
|
88
119
|
* Example: When I click "Contact Us"
|
|
89
120
|
* Example: And I click "aboutUs"
|
|
90
121
|
*
|
|
91
122
|
*/
|
|
92
123
|
When(/^(I|we)* click "([^"]*)?"$/, function (pronoundCase, item) {
|
|
93
|
-
browser.
|
|
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());
|
|
94
135
|
});
|
|
95
136
|
|
|
96
137
|
/**
|
|
@@ -99,35 +140,36 @@ When(/^(I|we)* click "([^"]*)?"$/, function (pronoundCase, item) {
|
|
|
99
140
|
* Example: And I reload the page
|
|
100
141
|
*
|
|
101
142
|
*/
|
|
102
|
-
When(/^(I|we)* reload
|
|
143
|
+
When(/^(I|we)* reload the page$/, function (pronoundCase) {
|
|
103
144
|
return browser.refresh(browser.getCurrentUrl());
|
|
104
145
|
});
|
|
105
146
|
|
|
147
|
+
|
|
106
148
|
/**
|
|
107
|
-
* Define the step of filling values in the form field specified
|
|
149
|
+
* Define the step of filling values in the form field specified element.
|
|
108
150
|
* Example: When I fill in "Username" with "John Smith"
|
|
109
151
|
*
|
|
110
152
|
*/
|
|
111
153
|
When(/^(I|we)* fill in "([^"]*)?" with "([^"]*)?"$/, function (pronoundCase, field, value) {
|
|
112
|
-
browser.
|
|
154
|
+
browser.setValue(field, value);
|
|
113
155
|
});
|
|
114
156
|
|
|
115
157
|
/**
|
|
116
|
-
* Fills in form field with specified
|
|
158
|
+
* Fills in form field with specified element
|
|
117
159
|
* Example: When I fill in "username" with:
|
|
118
160
|
*
|
|
119
161
|
*/
|
|
120
162
|
When(/^(I|we)* fill in "([^"]*)?" with:$/, function (pronoundCase, field) {
|
|
121
|
-
browser.
|
|
163
|
+
browser.setValue(field, '');
|
|
122
164
|
});
|
|
123
165
|
|
|
124
166
|
/**
|
|
125
|
-
* Fills in form field with specified
|
|
167
|
+
* Fills in form field with specified element
|
|
126
168
|
* Example: And I fill in "webshipco" for "username"
|
|
127
169
|
*
|
|
128
170
|
*/
|
|
129
171
|
When(/^(I|we)* fill in "([^"]*)?" for "([^"]*)?"$/, function (pronoundCase, value, field) {
|
|
130
|
-
browser.
|
|
172
|
+
browser.setValue(field, value);
|
|
131
173
|
});
|
|
132
174
|
|
|
133
175
|
/**
|
|
@@ -142,37 +184,56 @@ When(/^(I|we)* fill in "([^"]*)?" for "([^"]*)?"$/, function (pronoundCase, valu
|
|
|
142
184
|
*/
|
|
143
185
|
When(/^(I|we)* fill in the following:$/, function (pronoundCase, table) {
|
|
144
186
|
|
|
145
|
-
browser.
|
|
187
|
+
browser.setValue(table.rawTable[0][0], table.rawTable[0][1]);
|
|
146
188
|
table.rows().forEach(row => {
|
|
147
|
-
browser.
|
|
189
|
+
browser.setValue(row[0], row[1]);
|
|
190
|
+
// browser.fillTextInput(row[0], row[1]);
|
|
148
191
|
});
|
|
149
192
|
});
|
|
150
193
|
|
|
151
194
|
/**
|
|
152
|
-
* Selects option in select field
|
|
195
|
+
* Selects option in select field
|
|
153
196
|
* Example: When I select "mercedes" from "Cars"
|
|
154
197
|
*
|
|
155
198
|
*/
|
|
156
199
|
When(/^(I|we)* select "([^"]*)?" from "([^"]*)?"$/, function (pronoundCase, option, dropdownlist) {
|
|
157
|
-
|
|
200
|
+
|
|
201
|
+
return browser.click('select' + dropdownlist + ' option[value=' + option + ']');
|
|
158
202
|
});
|
|
159
203
|
|
|
160
204
|
/**
|
|
161
|
-
* Checks checkbox specified
|
|
205
|
+
* Checks checkbox specified
|
|
162
206
|
* Example: When I check "Remember me"
|
|
163
207
|
*
|
|
164
208
|
*/
|
|
165
209
|
When(/^(I|we)* check "([^"]*)?"$/, function (pronoundCase, item) {
|
|
166
|
-
browser.
|
|
210
|
+
browser.isSelected(item, function (result) {
|
|
211
|
+
if (!result.value) {
|
|
212
|
+
this.click(item);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
167
215
|
});
|
|
168
216
|
|
|
169
217
|
/**
|
|
170
|
-
* Unchecks checkbox specified
|
|
218
|
+
* Unchecks checkbox specified
|
|
171
219
|
* Example: When I uncheck "Remember me"
|
|
172
220
|
*
|
|
173
221
|
*/
|
|
174
222
|
When(/^(I|we)* uncheck "([^"]*)?"$/, function (pronoundCase, item) {
|
|
175
|
-
browser.
|
|
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);
|
|
176
237
|
});
|
|
177
238
|
|
|
178
239
|
/**
|
|
@@ -180,12 +241,30 @@ When(/^(I|we)* uncheck "([^"]*)?"$/, function (pronoundCase, item) {
|
|
|
180
241
|
* Example: Then I should be on the homepage
|
|
181
242
|
*
|
|
182
243
|
*/
|
|
183
|
-
Then(/^(I|we)* should
|
|
184
|
-
return browser.assert.
|
|
244
|
+
Then(/^(I|we)* should be on the homepage$/, function (pronoundCase) {
|
|
245
|
+
return browser.assert.urlMatches(browser.launch_url);
|
|
185
246
|
});
|
|
186
247
|
|
|
187
248
|
/**
|
|
188
|
-
* 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
|
|
189
268
|
* Example: Then I should be on "/"
|
|
190
269
|
* Example: And I should be on "/user/login"
|
|
191
270
|
* Example: And I should be on "http://google.com"
|
|
@@ -196,133 +275,303 @@ Then(/^(I|we)* should be on "([^"]*)?"$/, function (pronoundCase, url) {
|
|
|
196
275
|
});
|
|
197
276
|
|
|
198
277
|
/**
|
|
199
|
-
* Checks, that HTML response contains specific text
|
|
278
|
+
* Checks, that HTML response contains specific text
|
|
200
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
|
|
201
290
|
* Example: Then the response should not contain "Error: Ambiguous messages that are unclear"
|
|
202
291
|
*
|
|
203
292
|
*/
|
|
204
|
-
Then(/^the response should
|
|
205
|
-
return
|
|
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
|
+
|
|
299
|
+
|
|
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
|
+
};
|
|
206
309
|
});
|
|
207
310
|
|
|
208
311
|
/**
|
|
209
|
-
* Assert, that element contains a specific text value
|
|
210
|
-
* Example: Then I should see "
|
|
211
|
-
* 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
|
|
212
314
|
*
|
|
213
315
|
*/
|
|
214
|
-
Then(/^(I|we)* should
|
|
215
|
-
|
|
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
|
+
};
|
|
216
321
|
});
|
|
217
322
|
|
|
218
323
|
/**
|
|
219
|
-
* Assert, that element exists on page
|
|
324
|
+
* Assert, that element exists on current page
|
|
220
325
|
* Example: Then I should see a "body" element
|
|
221
|
-
*
|
|
326
|
+
*
|
|
327
|
+
*/
|
|
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) {
|
|
338
|
+
return browser.verify.visible(element);
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
/**
|
|
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
|
|
222
352
|
* Example: Then I should not see a "Username" element
|
|
223
|
-
* Example: Then I should not see an "img" element
|
|
224
353
|
*
|
|
225
354
|
*/
|
|
226
|
-
Then(/^(I|we)* should
|
|
227
|
-
return browser.
|
|
355
|
+
Then(/^(I|we)* should not see a "([^"]*)?" element$/, function (pronoundCase, element) {
|
|
356
|
+
return browser.verify.not.visible(element);
|
|
228
357
|
});
|
|
229
358
|
|
|
230
359
|
/**
|
|
231
|
-
* Assert, that element
|
|
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
|
|
232
370
|
* Example: Then the "body" element should contain "color:white;"
|
|
233
371
|
*
|
|
234
372
|
*/
|
|
235
|
-
Then(/^the "([^"]*)?" element should
|
|
236
|
-
|
|
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
|
+
};
|
|
237
384
|
});
|
|
238
385
|
|
|
239
386
|
/**
|
|
240
|
-
*
|
|
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
|
|
241
406
|
* Example: When I attach the file "profileIcon.jpg" to "profileIconUpload"
|
|
242
407
|
*
|
|
243
408
|
*/
|
|
244
409
|
When(/^(I|we)* attach the file "([^"]*)?" to "([^"]*)?"$/, function (pronoundCase, fileUrl, element) {
|
|
245
|
-
browser.
|
|
410
|
+
// browser.setValue(element, require('path').resolve(__dirname + fileUrl));
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Assert, that field contain a specific text
|
|
415
|
+
* Example: Then the "#username" field should contain "John Smith"
|
|
416
|
+
*
|
|
417
|
+
*/
|
|
418
|
+
Then(/^the "([^"]*)?" field should contain "([^"]*)?"$/, function (field, expectedText) {
|
|
419
|
+
|
|
420
|
+
return this.shouldSee = function (browser) {
|
|
421
|
+
browser.assert.textContains(field, expectedText);
|
|
422
|
+
};
|
|
246
423
|
});
|
|
247
424
|
|
|
248
425
|
/**
|
|
249
|
-
* Assert, that
|
|
250
|
-
* Example: Then the "username" field should contain "John Smith"
|
|
426
|
+
* Assert, that field does not contain a specific text
|
|
427
|
+
* Example: Then the "#username" field should not contain "John Smith"
|
|
251
428
|
*
|
|
252
429
|
*/
|
|
253
|
-
Then(/^the "([^"]*)?" field should
|
|
254
|
-
|
|
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
|
+
};
|
|
255
435
|
});
|
|
256
436
|
|
|
257
437
|
/**
|
|
258
|
-
* Assert, that checkbox with specified
|
|
259
|
-
* Example: Then the "PrivacyPolicy" checkbox should be checked
|
|
438
|
+
* Assert, that checkbox with specified element is should be checked
|
|
439
|
+
* Example: Then the "#PrivacyPolicy" checkbox should be checked
|
|
260
440
|
*
|
|
261
441
|
*/
|
|
262
|
-
Then(/^the "([^"]*)?" checkbox should
|
|
263
|
-
return browser.
|
|
442
|
+
Then(/^the "([^"]*)?" checkbox should be checked$/, function (checkbox) {
|
|
443
|
+
return browser.expect.element(checkbox).to.be.selected;
|
|
264
444
|
});
|
|
265
445
|
|
|
266
446
|
/**
|
|
267
|
-
*
|
|
268
|
-
* Example: Then the "
|
|
269
|
-
*
|
|
447
|
+
* Assert, that checkbox with specified element is should not be checked
|
|
448
|
+
* Example: Then the "#PrivacyPolicy" checkbox should not be checked
|
|
270
449
|
*
|
|
271
450
|
*/
|
|
272
|
-
Then(/^the "([^"]*)?" checkbox
|
|
273
|
-
return browser.
|
|
451
|
+
Then(/^the "([^"]*)?" checkbox should not be checked$/, function (checkbox) {
|
|
452
|
+
return browser.expect.element(checkbox).to.not.be.selected;
|
|
274
453
|
});
|
|
275
454
|
|
|
276
455
|
/**
|
|
277
|
-
*
|
|
278
|
-
* Example: Then the
|
|
279
|
-
* 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
|
|
280
458
|
*
|
|
281
459
|
*/
|
|
282
|
-
Then(/^the
|
|
283
|
-
return browser.
|
|
460
|
+
Then(/^the "([^"]*)?" checkbox is checked$/, function (checkbox) {
|
|
461
|
+
return browser.expect.element(checkbox).to.be.selected;
|
|
284
462
|
});
|
|
285
463
|
|
|
286
464
|
/**
|
|
287
|
-
*
|
|
288
|
-
* Example: Then the
|
|
289
|
-
* Example: And the checkbox "Remember Me" is not checked
|
|
465
|
+
* Check, whether the checkbox specified is not checked.
|
|
466
|
+
* Example: Then the "#rememberMe" checkbox is not checked
|
|
290
467
|
*
|
|
291
468
|
*/
|
|
292
|
-
Then(/^the
|
|
293
|
-
return browser.
|
|
469
|
+
Then(/^the "([^"]*)?" checkbox is not checked$/, function (checkbox) {
|
|
470
|
+
return browser.expect.element(checkbox).to.not.be.selected;
|
|
294
471
|
});
|
|
295
472
|
|
|
296
473
|
/**
|
|
297
|
-
*
|
|
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
|
|
494
|
+
*
|
|
495
|
+
*/
|
|
496
|
+
Then(/^the checkbox "([^"]*)?" is checked$/, function (checkbox) {
|
|
497
|
+
return browser.expect.element(checkbox).to.be.selected;
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
/**
|
|
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.
|
|
298
511
|
* Example: When I wait 1 second
|
|
299
512
|
* Example: When I wait 5 seconds
|
|
513
|
+
*
|
|
514
|
+
*/
|
|
515
|
+
When(/^(I|we)* wait (\d*) second(s)*$/, function (pronoundCase, number, withS) {
|
|
516
|
+
var waitTime = number * 1000;
|
|
517
|
+
return browser.pause(waitTime);
|
|
518
|
+
});
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Wait a max number of seconds until the element present.
|
|
300
522
|
* Example: When I wait max of 6 seconds
|
|
301
523
|
*
|
|
302
524
|
*/
|
|
303
|
-
When(/^(I|we)* wait
|
|
304
|
-
|
|
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);
|
|
305
528
|
});
|
|
306
529
|
|
|
307
530
|
/**
|
|
308
|
-
* Wait a specific number of minutes
|
|
531
|
+
* Wait a specific number of minutes.
|
|
309
532
|
* Example: When I wait 1 minute
|
|
310
533
|
* Example: When I wait 5 minutes
|
|
534
|
+
*
|
|
535
|
+
*/
|
|
536
|
+
When(/^(I|we)* wait (\d*) minute(s)*$/, function (pronoundCase, number, withS) {
|
|
537
|
+
var waitTime = number * 1000 * 60;
|
|
538
|
+
return browser.pause(waitTime);
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Wait a max number of minutes until the element present.
|
|
311
543
|
* Example: When I wait max of 6 minutes
|
|
312
544
|
*
|
|
313
545
|
*/
|
|
314
|
-
When(/^(I|we)* wait
|
|
315
|
-
|
|
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);
|
|
316
549
|
});
|
|
317
550
|
|
|
318
551
|
/**
|
|
319
|
-
* Checks, that the current page response status is equal
|
|
552
|
+
* Checks, that the current page response status is equal the specified code
|
|
320
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) {
|
|
558
|
+
request(currentURL.value, (error, response, body) => {
|
|
559
|
+
browser.assert.equal(response.statusCode, expectedStatusCode);
|
|
560
|
+
});
|
|
561
|
+
});
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Checks, that the current page response status is not equal the specified code
|
|
321
566
|
* Example: And the response status code should not be 404
|
|
322
567
|
*
|
|
323
568
|
*/
|
|
324
|
-
Then(/^the response status code should
|
|
325
|
-
return browser.
|
|
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);
|
|
573
|
+
});
|
|
574
|
+
});
|
|
326
575
|
});
|
|
327
576
|
|
|
328
577
|
/**
|
|
@@ -330,45 +579,75 @@ Then(/^the response status code should( not)* be (\d+)$/, function (negativeCase
|
|
|
330
579
|
* Example: Then I should see text matching "^T\w+" //pattern of word start with 'T'
|
|
331
580
|
*
|
|
332
581
|
*/
|
|
333
|
-
Then(/^(I|we)* should
|
|
334
|
-
// return browser.assert.textMatching(negativeCase, textPattern);
|
|
582
|
+
Then(/^(I|we)* should see text matching "([^"]*)?"$/, function (pronoundCase, textPattern) {
|
|
335
583
|
browser.elements('css selector', 'body', function (elements) {
|
|
336
584
|
elements.value.forEach(function (elementsObj) {
|
|
337
|
-
if (negativeCase) {
|
|
338
|
-
return browser.assert.not.textMatches(elementsObj, textPattern);
|
|
339
|
-
}
|
|
340
585
|
return browser.assert.textMatches(elementsObj, textPattern);
|
|
341
586
|
});
|
|
342
587
|
});
|
|
343
588
|
});
|
|
344
589
|
|
|
345
590
|
/**
|
|
346
|
-
* Checks, that page contains text matching specified pattern
|
|
347
|
-
* 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'
|
|
348
593
|
*
|
|
349
594
|
*/
|
|
350
|
-
Then(/^(I|we)* should
|
|
351
|
-
browser.elements('css selector',
|
|
595
|
+
Then(/^(I|we)* should not see text matching "([^"]*)?"$/, function (pronoundCase, textPattern) {
|
|
596
|
+
browser.elements('css selector', 'body', function (elements) {
|
|
352
597
|
elements.value.forEach(function (elementsObj) {
|
|
353
|
-
|
|
354
|
-
return browser.assert.not.textMatches(elementsObj, textPattern);
|
|
355
|
-
}
|
|
356
|
-
return browser.assert.textMatches(elementsObj, textPattern);
|
|
598
|
+
return browser.assert.not.textMatches(elementsObj, textPattern);
|
|
357
599
|
});
|
|
358
600
|
});
|
|
359
601
|
});
|
|
360
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
|
+
});
|
|
361
636
|
|
|
362
637
|
/**
|
|
363
638
|
* Checks, that current URL Path matches regular expression
|
|
364
639
|
* Example: Then the url should match "/contact-us.html"
|
|
365
640
|
*
|
|
366
641
|
*/
|
|
367
|
-
Then(/^the url should
|
|
368
|
-
|
|
369
|
-
if (negativeCase) {
|
|
370
|
-
return browser.assert.not.urlMatches(pattern);
|
|
371
|
-
}
|
|
642
|
+
Then(/^the url should match "([^"]*)?"$/, function (pattern) {
|
|
372
643
|
return browser.assert.urlMatches(pattern);
|
|
644
|
+
});
|
|
373
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);
|
|
374
653
|
});
|