webship-js 1.0.40 → 1.0.42
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 +1 -1
- package/.github/workflows/github-actions.yml +1 -1
- package/.gitlab-ci.yml +1 -1
- package/.yarn/install-state.gz +0 -0
- package/assets/config_templates/circleci-linux-chrome.conf.js +10 -1
- package/assets/config_templates/github-linux-chrome.conf.js +10 -1
- package/bitbucket-pipelines.yml +1 -2
- package/examples/test--when--i-scroll-left-right-functionality.html +207 -0
- package/nightwatch.conf.js +12 -3
- package/package.json +2 -2
- package/steplist.js +1 -1
- package/tests/features/test--when--i-attach-file-to-feild.feature +1 -2
- package/tests/features/test--when--i-scroll-left-right.feature +48 -0
- package/tests/step-definitions/webship.js +451 -150
|
@@ -1,73 +1,148 @@
|
|
|
1
|
-
const { Given} = require('@cucumber/cucumber');
|
|
2
|
-
const { When
|
|
3
|
-
const { Then} = require('@cucumber/cucumber');
|
|
1
|
+
const { Given } = require('@cucumber/cucumber');
|
|
2
|
+
const { When } = require('@cucumber/cucumber');
|
|
3
|
+
const { Then } = require('@cucumber/cucumber');
|
|
4
|
+
const {Before, After, BeforeStep, AfterStep} = require('@cucumber/cucumber');
|
|
5
|
+
|
|
4
6
|
|
|
5
7
|
const axios = require('axios');
|
|
8
|
+
const path = require('path');
|
|
6
9
|
|
|
7
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Safely pauses based on global config.
|
|
13
|
+
* Handles case where browser or globals may be undefined.
|
|
14
|
+
* @param {string} key
|
|
15
|
+
*/
|
|
16
|
+
function safePause(key) {
|
|
17
|
+
const time = (global.browser?.globals?.minimum_wait_time?.[key]) || 0;
|
|
18
|
+
if (time > 0 && global.browser?.pause) {
|
|
19
|
+
global.browser.pause(time);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
Before(function () {
|
|
24
|
+
safePause('before_scenario');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
After(function () {
|
|
28
|
+
safePause('after_scenario');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
BeforeStep(function () {
|
|
32
|
+
safePause('before_step');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
AfterStep(function () {
|
|
36
|
+
safePause('after_step');
|
|
37
|
+
});
|
|
38
|
+
|
|
8
39
|
/**
|
|
9
40
|
* Opens homepage.
|
|
10
41
|
*
|
|
11
|
-
* Example: Given I am on homepage
|
|
12
|
-
* Example: Given I am on the homepage
|
|
42
|
+
* Example #1: Given I am on homepage
|
|
43
|
+
* Example #2: Given I am on the homepage
|
|
44
|
+
* Example #2: Given I am on frontpage
|
|
45
|
+
* Example #3: Given I am on the frontpage
|
|
46
|
+
* Example #4: Given we are on homepage
|
|
47
|
+
* Example #5: Given on the homepage
|
|
48
|
+
* Example #6: Given on homepage
|
|
49
|
+
* Example #7: Given we are on the frontpage
|
|
50
|
+
* Example #8: Given on frontpage
|
|
51
|
+
*
|
|
13
52
|
*
|
|
14
53
|
*/
|
|
15
|
-
Given(/^(I am|we are)
|
|
16
|
-
|
|
54
|
+
Given(/^(I am |we are )?on( the)* (homepage|frontpage)$/, function (pronounCase, theCase, pageCase) {
|
|
55
|
+
browser.url(browser.launch_url);
|
|
56
|
+
let defaultTime = 3000;
|
|
57
|
+
if (browser.globals && browser.globals.minimum_wait_time && browser.globals.minimum_wait_time.page) {
|
|
58
|
+
defaultTime = browser.globals.minimum_wait_time.page;
|
|
59
|
+
}
|
|
60
|
+
return browser.waitForElementPresent('body', defaultTime);
|
|
17
61
|
});
|
|
18
62
|
|
|
19
63
|
/**
|
|
20
64
|
* Open specific page.
|
|
21
65
|
*
|
|
22
|
-
* Example: Given I am on "about-us.html"
|
|
66
|
+
* Example #1: Given I am on "/about-us.html"
|
|
67
|
+
* Example #2: Given we are on "/about-us.html"
|
|
68
|
+
* Example #3: Given I am on the "/about-us.html" page
|
|
69
|
+
* Example #4: Given we are on the "/about-us.html" page
|
|
70
|
+
* Example #5: Given on "/about-us.html"
|
|
71
|
+
* Example #6: Given on the "/about-us.html" page
|
|
23
72
|
*
|
|
24
73
|
*/
|
|
25
|
-
Given(/^(I am|we are)
|
|
26
|
-
|
|
74
|
+
Given(/^(I am |we are )*on( the)* "([^"]*)?"( page)*$/, function (pronounCase, theCase, url, pageCase) {
|
|
75
|
+
browser.url(browser.launch_url + url);
|
|
76
|
+
let defaultTime = 3000;
|
|
77
|
+
if (browser.globals && browser.globals.minimum_wait_time && browser.globals.minimum_wait_time.page) {
|
|
78
|
+
defaultTime = browser.globals.minimum_wait_time.page;
|
|
79
|
+
}
|
|
80
|
+
return browser.waitForElementPresent('body', defaultTime);
|
|
27
81
|
});
|
|
28
82
|
|
|
29
83
|
/**
|
|
30
84
|
* Go to homepage.
|
|
31
85
|
*
|
|
32
|
-
* Example: When I go to homepage
|
|
33
|
-
* Example: When I go to the homepage
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
86
|
+
* Example #1: When I go to homepage
|
|
87
|
+
* Example #2: When I go to the homepage
|
|
88
|
+
* Example #3: When I navigate to the homepage
|
|
89
|
+
* Example #4: When navigating to the homepage
|
|
90
|
+
* Example #5: When navigating to homepage
|
|
91
|
+
* Example #6: When navigating to the frontpage
|
|
92
|
+
* Example #7: When we go to the homepage
|
|
93
|
+
* Example #8: When we navigate to the homepage
|
|
94
|
+
*
|
|
95
|
+
*/
|
|
96
|
+
When(/^(I go |I navigate |we go |we navigate |navigating )?to( the)* (homepage|frontpage)$/, function (pronounCase, theCase, pageCase) {
|
|
97
|
+
browser.url(browser.launch_url);
|
|
98
|
+
let defaultTime = 3000;
|
|
99
|
+
if (browser.globals && browser.globals.minimum_wait_time && browser.globals.minimum_wait_time.page) {
|
|
100
|
+
defaultTime = browser.globals.minimum_wait_time.page;
|
|
101
|
+
}
|
|
102
|
+
return browser.waitForElementPresent('body', defaultTime);
|
|
38
103
|
});
|
|
39
104
|
|
|
40
105
|
/**
|
|
41
106
|
* Go to specific page.
|
|
42
107
|
*
|
|
43
|
-
* Example: When I go to "contact-us.html"
|
|
108
|
+
* Example #1: When I go to "/contact-us.html"
|
|
109
|
+
* Example #2: When I go to "/user/login"
|
|
110
|
+
* Example #3: When I navigate to "/admin/dashboard"
|
|
111
|
+
* Example #4: When navigating to "/products"
|
|
112
|
+
* Example #7: When we go to "/products"
|
|
113
|
+
* Example #8: When we navigate to "/terms"
|
|
44
114
|
*
|
|
45
115
|
*/
|
|
46
|
-
When(/^(I|we
|
|
47
|
-
|
|
116
|
+
When(/^(I go |I navigate |we go |we navigate |navigating )?to "([^"]*)?"$/, function (pronounCase, url) {
|
|
117
|
+
browser.url(browser.launch_url + url);
|
|
118
|
+
let defaultTime = 3000;
|
|
119
|
+
if (browser.globals && browser.globals.minimum_wait_time && browser.globals.minimum_wait_time.page) {
|
|
120
|
+
defaultTime = browser.globals.minimum_wait_time.page;
|
|
121
|
+
}
|
|
122
|
+
return browser.waitForElementPresent('body', defaultTime);
|
|
48
123
|
});
|
|
49
124
|
|
|
50
125
|
/**
|
|
51
126
|
* Asserting a text in the page.
|
|
52
127
|
*
|
|
53
|
-
* Example:
|
|
54
|
-
*
|
|
128
|
+
* Example #1: Then I should see "Welcome"
|
|
129
|
+
* Example #2: Then we should see "Your accounts for the group is public"
|
|
55
130
|
*
|
|
56
131
|
*/
|
|
57
|
-
Then(/^(I|we)*
|
|
132
|
+
Then(/^(I |we )*should see "([^"]*)?"$/, function (pronounCase, expectedText) {
|
|
58
133
|
return this.shouldSee = function (browser) {
|
|
59
134
|
browser.assert.textContains("html", expectedText);
|
|
60
135
|
};
|
|
61
136
|
});
|
|
62
137
|
|
|
63
138
|
/**
|
|
64
|
-
* Asserting a text
|
|
139
|
+
* Asserting a text in the page.
|
|
65
140
|
*
|
|
66
|
-
* Example:
|
|
67
|
-
*
|
|
141
|
+
* Example #1: Then I should not see "Access denied"
|
|
142
|
+
* Example #2: Then we should not see "Edit layout"
|
|
68
143
|
*
|
|
69
144
|
*/
|
|
70
|
-
Then(/^(I|we)*
|
|
145
|
+
Then(/^(I |we )*should not see "([^"]*)?"$/, function (pronounCase, expectedText) {
|
|
71
146
|
return this.shouldSee = function (browser) {
|
|
72
147
|
browser.assert.not.textContains("html", expectedText);
|
|
73
148
|
};
|
|
@@ -79,7 +154,7 @@ Then(/^(I|we)* should not see "([^"]*)?"$/, function (pronounCase, expectedText)
|
|
|
79
154
|
* Example: When I move forward one page
|
|
80
155
|
*
|
|
81
156
|
*/
|
|
82
|
-
When(/^(I|we)*
|
|
157
|
+
When(/^(I |we )*move forward one page$/, function (pronounCase) {
|
|
83
158
|
return browser.forward();
|
|
84
159
|
});
|
|
85
160
|
|
|
@@ -89,7 +164,7 @@ When(/^(I|we)* move forward one page$/, function (pronounCase) {
|
|
|
89
164
|
* Example: When I move backward one page
|
|
90
165
|
*
|
|
91
166
|
*/
|
|
92
|
-
When(/^(I|we)*
|
|
167
|
+
When(/^(I |we )*move backward one page$/, function (pronounCase) {
|
|
93
168
|
return browser.back();
|
|
94
169
|
});
|
|
95
170
|
|
|
@@ -101,7 +176,7 @@ When(/^(I|we)* move backward one page$/, function (pronounCase) {
|
|
|
101
176
|
* Example: And I press the "Save as" button
|
|
102
177
|
*
|
|
103
178
|
*/
|
|
104
|
-
When(/^(I|we)*
|
|
179
|
+
When(/^(I |we )*press( the)* "([^"]*)?"( button)*$/, function (pronounCase, theCase, element, buttonCase) {
|
|
105
180
|
browser.click("[value='" + element +"']");
|
|
106
181
|
});
|
|
107
182
|
|
|
@@ -115,7 +190,7 @@ When(/^(I|we)* press( the)* "([^"]*)?"( button)*$/, function (pronounCase, theCa
|
|
|
115
190
|
* Example: And I press "save-name" by "data-selector" attr
|
|
116
191
|
*
|
|
117
192
|
*/
|
|
118
|
-
When(/^(I|we)*
|
|
193
|
+
When(/^(I |we )*press "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronounCase, attrValue, itsCase, attr, attrCase) {
|
|
119
194
|
|
|
120
195
|
const hasASpace = attrValue.indexOf(' ');
|
|
121
196
|
var selector = '';
|
|
@@ -143,20 +218,20 @@ When(/^(I|we)* press "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, func
|
|
|
143
218
|
* Example: And I click "aboutUs"
|
|
144
219
|
*
|
|
145
220
|
*/
|
|
146
|
-
When(/^(I|we)*
|
|
221
|
+
When(/^(I |we )*click "([^"]*)?"$/, function (pronounCase, item) {
|
|
147
222
|
return browser.click("link text", item);
|
|
148
223
|
});
|
|
149
224
|
|
|
150
225
|
/**
|
|
151
226
|
* Click Link with specified element.
|
|
152
227
|
*
|
|
153
|
-
* Example: When I click "#
|
|
154
|
-
* Example: When I click "
|
|
155
|
-
* Example: And I click "
|
|
156
|
-
* Example: And I click "
|
|
228
|
+
* Example: When I click "#about-us-id" by attr
|
|
229
|
+
* Example: When I click "data-selector-about" by attribute
|
|
230
|
+
* Example: And I click "about-us-css" by "class" attr
|
|
231
|
+
* Example: And I click "about-us-id" by its "id" attribute
|
|
157
232
|
*
|
|
158
233
|
*/
|
|
159
|
-
When(/^(I|we)*
|
|
234
|
+
When(/^(I |we )*click "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronounCase, attrValue, itsCase, attr, attrCase) {
|
|
160
235
|
|
|
161
236
|
const hasASpace = attrValue.indexOf(' ');
|
|
162
237
|
var selector = '';
|
|
@@ -181,23 +256,13 @@ When(/^(I|we)* click "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, func
|
|
|
181
256
|
/**
|
|
182
257
|
* Reloads current page.
|
|
183
258
|
*
|
|
184
|
-
* Example: When I reload
|
|
185
|
-
* Example:
|
|
259
|
+
* Example #1: When I reload
|
|
260
|
+
* Example #2: And I reload the page
|
|
261
|
+
* Example #3: And we reload page
|
|
262
|
+
* Example #4: And we reload the page
|
|
186
263
|
*
|
|
187
264
|
*/
|
|
188
|
-
|
|
189
|
-
When(/^(I|we)* reload page$/, function (pronounCase) {
|
|
190
|
-
return browser.refresh(browser.getCurrentUrl());
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Reloads current page.
|
|
195
|
-
*
|
|
196
|
-
* Example: When I reload the page
|
|
197
|
-
* Example: And I reload the page
|
|
198
|
-
*
|
|
199
|
-
*/
|
|
200
|
-
When(/^(I|we)* reload( the)* page$/, function (pronounCase, theCase) {
|
|
265
|
+
When(/^(I |we )*reload( the)*( page)*$/, function (pronounCase, theCase, pageCase) {
|
|
201
266
|
return browser.refresh(browser.getCurrentUrl());
|
|
202
267
|
});
|
|
203
268
|
|
|
@@ -207,7 +272,7 @@ When(/^(I|we)* reload( the)* page$/, function (pronounCase, theCase) {
|
|
|
207
272
|
* Example: When I fill in "Username" with "John Smith"
|
|
208
273
|
*
|
|
209
274
|
*/
|
|
210
|
-
When(/^(I|we)*
|
|
275
|
+
When(/^(I |we )*fill in "([^"]*)?" with "([^"]*)?"$/, function (pronounCase, field, value) {
|
|
211
276
|
const elementField = browser.element.findByText(field, { exact: true });
|
|
212
277
|
browser.getAttribute(elementField, 'for', function (eleAttribute) {
|
|
213
278
|
return browser.setValue('#' + eleAttribute.value, value);
|
|
@@ -223,7 +288,7 @@ When(/^(I|we)* fill in "([^"]*)?" with "([^"]*)?"$/, function (pronounCase, fiel
|
|
|
223
288
|
* Example: And I fill in "Your full name" with "John Smith" by its "placeholder" attribute
|
|
224
289
|
*
|
|
225
290
|
*/
|
|
226
|
-
When(/^(I|we)*
|
|
291
|
+
When(/^(I |we )*fill in "([^"]*)?" with "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronounCase, attrValue, txtValue, itsCase, attr, attrCase) {
|
|
227
292
|
|
|
228
293
|
const hasASpace = attrValue.indexOf(' ');
|
|
229
294
|
var selector = '';
|
|
@@ -251,7 +316,7 @@ When(/^(I|we)* fill in "([^"]*)?" with "([^"]*)?" by( its)*( "([^"]*)?")* (attri
|
|
|
251
316
|
* Example: When I fill in "Username" with:
|
|
252
317
|
*
|
|
253
318
|
*/
|
|
254
|
-
When(/^(I|we)*
|
|
319
|
+
When(/^(I |we )*fill in "([^"]*)?" with:$/, function (pronounCase, field) {
|
|
255
320
|
const elementField = browser.element.findByText(field, { exact: true });
|
|
256
321
|
browser.getAttribute(elementField, 'for', function (eleAttribute) {
|
|
257
322
|
return browser.setValue('#' + eleAttribute.value, '');
|
|
@@ -267,7 +332,7 @@ When(/^(I|we)* fill in "([^"]*)?" with:$/, function (pronounCase, field) {
|
|
|
267
332
|
* Example: And I fill in "Your full name" with: by its "placeholder" attribute
|
|
268
333
|
*
|
|
269
334
|
*/
|
|
270
|
-
When(/^(I|we)*
|
|
335
|
+
When(/^(I |we )*fill in "([^"]*)?" with: by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronounCase, attrValue , itsCase, attr, attrCase) {
|
|
271
336
|
|
|
272
337
|
const hasASpace = attrValue.indexOf(' ');
|
|
273
338
|
var selector = '';
|
|
@@ -291,10 +356,11 @@ When(/^(I|we)* fill in "([^"]*)?" with: by( its)*( "([^"]*)?")* (attribute|attr)
|
|
|
291
356
|
/**
|
|
292
357
|
* Fill in value for input type text by its Label.
|
|
293
358
|
*
|
|
294
|
-
* Example: When I fill in "jon-smith" for "Username"
|
|
359
|
+
* Example #1: When I fill in "jon-smith" for "Username"
|
|
360
|
+
* Example #2: When we fill in "Testing" for "Organization options"
|
|
295
361
|
*
|
|
296
362
|
*/
|
|
297
|
-
When(/^(I|we)*
|
|
363
|
+
When(/^(I |we )*fill in "([^"]*)?" for "([^"]*)?"$/, function (pronounCase, value, field) {
|
|
298
364
|
const elementField = browser.element.findByText(field, { exact: true });
|
|
299
365
|
browser.getAttribute(elementField, 'for', function (eleAttribute) {
|
|
300
366
|
return browser.setValue('#' + eleAttribute.value, value);
|
|
@@ -304,13 +370,13 @@ When(/^(I|we)* fill in "([^"]*)?" for "([^"]*)?"$/, function (pronounCase, value
|
|
|
304
370
|
/**
|
|
305
371
|
* Fill in value for input type text by its attribute.
|
|
306
372
|
*
|
|
307
|
-
* Example: When I fill in "John Smith" for "#uname" by attr
|
|
308
|
-
* Example: When I fill in "John Smith" for "uname" by attr
|
|
309
|
-
* Example: And I fill in "1234" for "
|
|
310
|
-
* Example: And I fill in "John Smith" for "Your full name" by its "placeholder" attribute
|
|
373
|
+
* Example #1: When I fill in "John Smith" for "#uname" by attr
|
|
374
|
+
* Example #2: When I fill in "John Smith" for "uname" by attr
|
|
375
|
+
* Example #3: And I fill in "1234" for "password" by "class" attr
|
|
376
|
+
* Example #4: And I fill in "John Smith" for "Your full name" by its "placeholder" attribute
|
|
311
377
|
*
|
|
312
378
|
*/
|
|
313
|
-
When(/^(I|we)*
|
|
379
|
+
When(/^(I |we )*fill in "([^"]*)?" for "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronounCase, txtValue, attrValue, itsCase, attr, attrCase) {
|
|
314
380
|
|
|
315
381
|
const hasASpace = attrValue.indexOf(' ');
|
|
316
382
|
var selector = '';
|
|
@@ -340,7 +406,7 @@ When(/^(I|we)* fill in "([^"]*)?" for "([^"]*)?" by( its)*( "([^"]*)?")* (attrib
|
|
|
340
406
|
* | Password | 1234 |
|
|
341
407
|
*/
|
|
342
408
|
|
|
343
|
-
When(/^(I|we)*
|
|
409
|
+
When(/^(I |we )*fill in( the)* following:$/, function (pronounCase, theCase, table) {
|
|
344
410
|
|
|
345
411
|
var elementField = browser.element.findByText(table.rawTable[0][0], { exact: true });
|
|
346
412
|
browser.getAttribute(elementField, 'for', function (eleAttribute) {
|
|
@@ -360,15 +426,15 @@ When(/^(I|we)* fill in( the)* following:$/, function (pronounCase, theCase, tabl
|
|
|
360
426
|
* Fill in value for input type text by its attributeFill form fields of type
|
|
361
427
|
* input Text with the provided table according to their attributes.
|
|
362
428
|
*
|
|
363
|
-
* Example: When I fill in the following: by attr
|
|
429
|
+
* Example #1: When I fill in the following: by attr
|
|
364
430
|
* | #uname | John Smith |
|
|
365
|
-
* |
|
|
431
|
+
* | password | 1234 |
|
|
366
432
|
*
|
|
367
|
-
* Example: When I fill in the following: by its "placeholder" attribute
|
|
433
|
+
* Example #2: When I fill in the following: by its "placeholder" attribute
|
|
368
434
|
* | Your full name | John Smith |
|
|
369
435
|
* | Your Password | 1234 |
|
|
370
436
|
*/
|
|
371
|
-
When(/^(I|we)*
|
|
437
|
+
When(/^(I |we )*fill in( the)* following: by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronounCase, theCase, itsCase, attr, attrCase, table) {
|
|
372
438
|
|
|
373
439
|
var hasASpace = table.rawTable[0][0].indexOf(' ');
|
|
374
440
|
var selector = '';
|
|
@@ -414,13 +480,14 @@ When(/^(I|we)* fill in( the)* following: by( its)*( "([^"]*)?")* (attribute|attr
|
|
|
414
480
|
});
|
|
415
481
|
|
|
416
482
|
/**
|
|
417
|
-
* Selecting the option in the dropdown list field by its text label
|
|
418
|
-
*
|
|
419
|
-
* Example: When I select "
|
|
420
|
-
* Example: When I select "
|
|
483
|
+
* Selecting the option in the dropdown list field by its text label.
|
|
484
|
+
*
|
|
485
|
+
* Example #1: When I select "Mercedes" from "Cars"
|
|
486
|
+
* Example #2: When I select "saab" from "#cars"
|
|
487
|
+
* Example #3: When I select "Mercedes" from "cars"
|
|
421
488
|
*
|
|
422
489
|
*/
|
|
423
|
-
When(/^(I|we)*
|
|
490
|
+
When(/^(I |we )*select "([^"]*)?" from "([^"]*)?"$/, function (pronounCase, option, selectList) {
|
|
424
491
|
|
|
425
492
|
const hasASpace = selectList.indexOf(' ');
|
|
426
493
|
|
|
@@ -451,64 +518,90 @@ When(/^(I|we)* select "([^"]*)?" from "([^"]*)?"$/, function (pronounCase, optio
|
|
|
451
518
|
/**
|
|
452
519
|
* Checks checkbox specified.
|
|
453
520
|
*
|
|
454
|
-
* Example: When I check "Remember me"
|
|
521
|
+
* Example #1: When I check "Remember me"
|
|
522
|
+
* Example #2: When we check "Put site into maintenance mode"
|
|
455
523
|
*
|
|
456
524
|
*/
|
|
457
|
-
When(/^(I|we)*
|
|
525
|
+
When(/^(I |we )*check "([^"]*)?"$/, function (pronounCase, item) {
|
|
458
526
|
browser.checkItem(item);
|
|
459
527
|
});
|
|
460
528
|
|
|
461
529
|
/**
|
|
462
530
|
* Unchecks checkbox specified.
|
|
463
531
|
*
|
|
464
|
-
* Example: When I uncheck "Remember me"
|
|
532
|
+
* Example #1: When I uncheck "Remember me"
|
|
533
|
+
* Example #2: When we uncheck "Put site into maintenance mode"
|
|
465
534
|
*
|
|
466
535
|
*/
|
|
467
|
-
When(/^(I|we)*
|
|
536
|
+
When(/^(I |we )*uncheck "([^"]*)?"$/, function (pronounCase, item) {
|
|
468
537
|
browser.uncheckItem(item);
|
|
469
538
|
});
|
|
470
539
|
|
|
471
540
|
/**
|
|
472
541
|
* Verify, that current page is the homepage.
|
|
473
542
|
*
|
|
474
|
-
* Example: Then I should be on homepage
|
|
475
|
-
* Example:
|
|
543
|
+
* Example #1: Then I should be on homepage
|
|
544
|
+
* Example #2: And I should be on the homepage
|
|
545
|
+
* Example #3: Then I should be on frontpage
|
|
546
|
+
* Example #4: And should be on the homepage
|
|
547
|
+
* Example #5: Then should be on homepage
|
|
548
|
+
* Example #6: And we should be on homepage
|
|
549
|
+
* Example #7: Then should be on frontpage
|
|
550
|
+
* Example #8: And we should be on the homepage
|
|
476
551
|
*
|
|
477
552
|
*/
|
|
478
|
-
Then(/^(I|we)*
|
|
553
|
+
Then(/^(I |we )*should be on( the)* (homepage|frontpage)$/, function (pronounCase, theCase, pageCase) {
|
|
479
554
|
return browser.assert.urlMatches(browser.launch_url);
|
|
480
555
|
});
|
|
481
556
|
|
|
482
557
|
/**
|
|
483
558
|
* Verify, that current page is the homepage.
|
|
484
559
|
*
|
|
485
|
-
* Example: Then I should not be on homepage
|
|
560
|
+
* Example #1: Then I should not be on homepage
|
|
561
|
+
* Example #2: And I should not be on the homepage
|
|
562
|
+
* Example #3: Then I should not be on frontpage
|
|
563
|
+
* Example #4: Then we should not be on homepage
|
|
564
|
+
* Example #5: Then should not be on the homepage
|
|
565
|
+
* Example #6: And we should not be on frontpage
|
|
566
|
+
* Example #7: And we should not be on the homepage
|
|
486
567
|
*
|
|
487
568
|
*/
|
|
488
|
-
Then(/^(I|we)*
|
|
569
|
+
Then(/^(I |we )*should not be on( the)* (homepage|frontpage)$/, function (pronounCase, theCase, pageCase) {
|
|
489
570
|
return browser.assert.not.urlMatches(browser.launch_url);
|
|
490
571
|
});
|
|
491
572
|
|
|
492
573
|
/**
|
|
493
|
-
* Verify, that current page is
|
|
574
|
+
* Verify, that current page path is equal to specified path.
|
|
494
575
|
*
|
|
495
|
-
* Example: Then I should
|
|
576
|
+
* Example #1: Then I should be on "/"
|
|
577
|
+
* Example #2: And I should be on "/user/login"
|
|
578
|
+
* Example #3: And I should be on "https://un.org"
|
|
579
|
+
* Example #4: Then we should be on the "/" page
|
|
580
|
+
* Example #5: And we should be on "/user/login"
|
|
581
|
+
* Example #6: And we should be on "https://google.com"
|
|
582
|
+
* Example #7: Then should be on the "/user/reset" page
|
|
583
|
+
* Example #8: And we should be on "https://x.com"
|
|
496
584
|
*
|
|
497
585
|
*/
|
|
498
|
-
Then(/^(I|we)*
|
|
499
|
-
return browser.assert.
|
|
586
|
+
Then(/^(I |we )*should be on( the)* "([^"]*)?"( page)*$/, function (pronounCase, theCase, url, pageCase) {
|
|
587
|
+
return browser.assert.urlContains(url);
|
|
500
588
|
});
|
|
501
589
|
|
|
502
590
|
/**
|
|
503
|
-
* Verify, that current page path
|
|
591
|
+
* Verify, that current page path dose not equal to specified path.
|
|
504
592
|
*
|
|
505
|
-
* Example: Then I should be on "/"
|
|
506
|
-
* Example:
|
|
507
|
-
* Example:
|
|
593
|
+
* Example #1: Then I should not be on "/"
|
|
594
|
+
* Example #2: And I should not be on "/user/login"
|
|
595
|
+
* Example #3: And I should not be on "https://un.org"
|
|
596
|
+
* Example #4: Then we should not be on the "/" page
|
|
597
|
+
* Example #5: And we should not be on "/user/login"
|
|
598
|
+
* Example #6: Then we should not be on "https://google.com"
|
|
599
|
+
* Example #7: And should not be on "/user/reset"
|
|
600
|
+
* Example #8: And we should not be on the "https://x.com" page
|
|
508
601
|
*
|
|
509
602
|
*/
|
|
510
|
-
Then(/^(I|we)*
|
|
511
|
-
return browser.assert.urlContains(url);
|
|
603
|
+
Then(/^(I |we )*should not be on( the)* "([^"]*)?"( page)*$/, function (pronounCase, theCase, url, pageCase) {
|
|
604
|
+
return browser.assert.not.urlContains(url);
|
|
512
605
|
});
|
|
513
606
|
|
|
514
607
|
/**
|
|
@@ -525,9 +618,9 @@ Then(/^(the )*"([^"]*)?" link should contain "([^"]*)?"$/, function (theCase, el
|
|
|
525
618
|
/**
|
|
526
619
|
* Verify, that the current link contains the specified URL, found by its attributes.
|
|
527
620
|
*
|
|
528
|
-
* Example: Then the "#
|
|
529
|
-
* Example: And the "aboutUs" link should contain "about" by its "class" attribute
|
|
530
|
-
* Example: And the ".contactUs" link should contain "/contact-" by attr
|
|
621
|
+
* Example #1: Then the "#about-us-id" link should contain "about" by attr
|
|
622
|
+
* Example #2: And the "aboutUs" link should contain "about" by its "class" attribute
|
|
623
|
+
* Example #3: And the ".contactUs" link should contain "/contact-" by attr
|
|
531
624
|
*
|
|
532
625
|
*/
|
|
533
626
|
Then(/^(the )*"([^"]*)?" link should contain "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (theCase, attrValue, url, itsCase, attr, attrCase) {
|
|
@@ -554,7 +647,7 @@ Then(/^(the )*"([^"]*)?" link should contain "([^"]*)?" by( its)*( "([^"]*)?")*
|
|
|
554
647
|
/**
|
|
555
648
|
* Checks, that HTML response contains specific text.
|
|
556
649
|
*
|
|
557
|
-
* Example: Then the response should contain "Welcome visitor, How can I help you?"
|
|
650
|
+
* Example #1: Then the response should contain "Welcome visitor, How can I help you?"
|
|
558
651
|
*
|
|
559
652
|
*/
|
|
560
653
|
Then(/^(the )*response should contain "([^"]*)?"$/, function (theCase, expectedText) {
|
|
@@ -564,9 +657,9 @@ Then(/^(the )*response should contain "([^"]*)?"$/, function (theCase, expectedT
|
|
|
564
657
|
});
|
|
565
658
|
|
|
566
659
|
/**
|
|
567
|
-
* Checks, that HTML response contains specific text.
|
|
660
|
+
* Checks, that HTML response dose not contains specific text.
|
|
568
661
|
*
|
|
569
|
-
* Example: Then the response should not contain "
|
|
662
|
+
* Example #1: Then the response should not contain "Welcome visitor, How can I help you?"
|
|
570
663
|
*
|
|
571
664
|
*/
|
|
572
665
|
Then(/^(the )*response should not contain "([^"]*)?"$/, function (theCase, expectedText) {
|
|
@@ -575,14 +668,14 @@ Then(/^(the )*response should not contain "([^"]*)?"$/, function (theCase, expec
|
|
|
575
668
|
};
|
|
576
669
|
});
|
|
577
670
|
|
|
578
|
-
|
|
579
671
|
/**
|
|
580
672
|
* Assert, that input text contains a specific value by its label.
|
|
581
673
|
*
|
|
582
|
-
* Example: Then I should see "John Smith" in the "Username" element
|
|
674
|
+
* Example #1: Then I should see "John Smith" in the "Username" element
|
|
675
|
+
* Example #2: Then I should not see "Joe Smith" in the "Username" element
|
|
583
676
|
*
|
|
584
677
|
*/
|
|
585
|
-
Then(/^(I|we)*
|
|
678
|
+
Then(/^(I |we )*should see "([^"]*)?" in( the)* "([^"]*)?" element$/, function (pronounCase, expectedText, theCase , element) {
|
|
586
679
|
const elementField = browser.element.findByText(element, { exact: true });
|
|
587
680
|
browser.getAttribute(elementField, 'for', function (eleAttribute) {
|
|
588
681
|
return this.shouldSee = function (browser) {
|
|
@@ -598,7 +691,7 @@ Then(/^(I|we)* should see "([^"]*)?" in( the)* "([^"]*)?" element$/, function (p
|
|
|
598
691
|
* Example: Then I should see "1234" in the "pwordcss" element by attr
|
|
599
692
|
*
|
|
600
693
|
*/
|
|
601
|
-
Then(/^(I|we)*
|
|
694
|
+
Then(/^(I |we )*should see "([^"]*)?" in( the)* "([^"]*)?" element by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronounCase, expectedText, theCase, attrValue, itsCase, attr, attrCase) {
|
|
602
695
|
|
|
603
696
|
const hasASpace = attrValue.indexOf(' ');
|
|
604
697
|
|
|
@@ -624,7 +717,7 @@ Then(/^(I|we)* should see "([^"]*)?" in( the)* "([^"]*)?" element by( its)*( "([
|
|
|
624
717
|
* Example: Then I should not see "Joe Smith" in the "Username" element
|
|
625
718
|
*
|
|
626
719
|
*/
|
|
627
|
-
Then(/^(I|we)*
|
|
720
|
+
Then(/^(I |we )*should not see "([^"]*)?" in( the)* "([^"]*)?" element$/, function (pronounCase, expectedText, theCase, element) {
|
|
628
721
|
|
|
629
722
|
const elementField = browser.element.findByText(element, { exact: true });
|
|
630
723
|
browser.getAttribute(elementField, 'for', function (eleAttribute) {
|
|
@@ -641,7 +734,7 @@ Then(/^(I|we)* should not see "([^"]*)?" in( the)* "([^"]*)?" element$/, functio
|
|
|
641
734
|
* Example: Then I should not see "1234" in the "pwordcss" element by attr
|
|
642
735
|
*
|
|
643
736
|
*/
|
|
644
|
-
Then(/^(I|we)*
|
|
737
|
+
Then(/^(I |we )*should not see "([^"]*)?" in( the)* "([^"]*)?" element by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronounCase, expectedText, theCase, attrValue, itsCase, attr, attrCase) {
|
|
645
738
|
|
|
646
739
|
const hasASpace = attrValue.indexOf(' ');
|
|
647
740
|
|
|
@@ -667,7 +760,7 @@ Then(/^(I|we)* should not see "([^"]*)?" in( the)* "([^"]*)?" element by( its)*(
|
|
|
667
760
|
* Example: Then I should see a "Username" element
|
|
668
761
|
*
|
|
669
762
|
*/
|
|
670
|
-
Then(/^(I|we)*
|
|
763
|
+
Then(/^(I |we )*should see (a|an) "([^"]*)?" element$/, function (pronounCase, aAnCase, element) {
|
|
671
764
|
const elementField = browser.element.findByText(element, { exact: true });
|
|
672
765
|
browser.getAttribute(elementField, 'for', function (eleAttribute) {
|
|
673
766
|
return browser.verify.visible('#' + eleAttribute.value);
|
|
@@ -681,7 +774,7 @@ Then(/^(I|we)* should see (a|an) "([^"]*)?" element$/, function (pronounCase, aA
|
|
|
681
774
|
* Example: Then I should see a "pwordcss" element by attr
|
|
682
775
|
*
|
|
683
776
|
*/
|
|
684
|
-
Then(/^(I|we)*
|
|
777
|
+
Then(/^(I |we )*should see (a|an) "([^"]*)?" element by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronounCase, aAnCase, attrValue, itsCase, attr, attrCase) {
|
|
685
778
|
|
|
686
779
|
const hasASpace = attrValue.indexOf(' ');
|
|
687
780
|
|
|
@@ -705,7 +798,7 @@ Then(/^(I|we)* should see (a|an) "([^"]*)?" element by( its)*( "([^"]*)?")* (att
|
|
|
705
798
|
* Example: Then I should not see a "Username" element
|
|
706
799
|
*
|
|
707
800
|
*/
|
|
708
|
-
Then(/^(I|we)*
|
|
801
|
+
Then(/^(I |we )*should not see (a|an) "([^"]*)?" element$/, function (pronounCase, aAnCase, element) {
|
|
709
802
|
browser.assert.not.textContains("html", element);
|
|
710
803
|
});
|
|
711
804
|
|
|
@@ -716,7 +809,7 @@ Then(/^(I|we)* should not see (a|an) "([^"]*)?" element$/, function (pronounCase
|
|
|
716
809
|
* Example: And I should not see a "countryCss" element by attr
|
|
717
810
|
*
|
|
718
811
|
*/
|
|
719
|
-
Then(/^(I|we)*
|
|
812
|
+
Then(/^(I |we )*should not see (a|an) "([^"]*)?" element by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronounCase, aAnCase, attrValue, itsCase, attr, attrCase) {
|
|
720
813
|
|
|
721
814
|
const hasASpace = attrValue.indexOf(' ');
|
|
722
815
|
|
|
@@ -756,9 +849,9 @@ Then(/^(the )*"([^"]*)?" element should contain "([^"]*)?"$/, function (theCase
|
|
|
756
849
|
/**
|
|
757
850
|
* Assert, that element contains a specific CSS style.
|
|
758
851
|
*
|
|
759
|
-
* Example: Then the "body" element should not contain "color:white;"
|
|
760
|
-
* Example: Then the "#uname" element should not contain "border:solid 5px red;"
|
|
761
|
-
* Example: Then the "pword" element should not contain "font-size: 26px;"
|
|
852
|
+
* Example #1: Then the "body" element should not contain "color:white;"
|
|
853
|
+
* Example #2: Then the "#uname" element should not contain "border:solid 5px red;"
|
|
854
|
+
* Example #3: Then the "pword" element should not contain "font-size: 26px;"
|
|
762
855
|
*/
|
|
763
856
|
Then(/^(the )*"([^"]*)?" element should not contain "([^"]*)?"$/, function (theCase, selector, elementCss) {
|
|
764
857
|
|
|
@@ -776,14 +869,25 @@ Then(/^(the )*"([^"]*)?" element should not contain "([^"]*)?"$/, function (theC
|
|
|
776
869
|
/**
|
|
777
870
|
* Attaches file to field.
|
|
778
871
|
*
|
|
779
|
-
* Example: When I attach the file "profileIcon.jpg" to "#
|
|
872
|
+
* Example: When I attach the file "profileIcon.jpg" to "#profile-icon-upload"
|
|
780
873
|
*
|
|
781
874
|
*/
|
|
782
|
-
When(/^(I|we)*
|
|
783
|
-
|
|
784
|
-
|
|
875
|
+
When(/^(I |we )*attach( the)* file "([^"]*)?" to "([^"]*)?"$/, function (pronounCase, theCase, fileName, element) {
|
|
876
|
+
// Construct local file path.
|
|
877
|
+
let assetsFolder;
|
|
878
|
+
if (browser.globals && browser.globals.assets_folder) {
|
|
879
|
+
assetsFolder = browser.globals.assets_folder;
|
|
880
|
+
} else {
|
|
881
|
+
assetsFolder = path.join(__dirname, '/tests/assets/');
|
|
882
|
+
}
|
|
785
883
|
|
|
786
|
-
|
|
884
|
+
const localFilePath = path.resolve(assetsFolder, fileName);
|
|
885
|
+
|
|
886
|
+
browser.pause(5000);
|
|
887
|
+
browser.uploadFile(element, localFilePath);
|
|
888
|
+
browser.pause(10000);
|
|
889
|
+
return browser.setValue(element, fileName);
|
|
890
|
+
|
|
787
891
|
});
|
|
788
892
|
|
|
789
893
|
/**
|
|
@@ -898,12 +1002,18 @@ Then(/^(the )*checkbox "([^"]*)?" is not checked$/, function (theCase, checkbox)
|
|
|
898
1002
|
/**
|
|
899
1003
|
* Wait a specific number of seconds.
|
|
900
1004
|
*
|
|
901
|
-
|
|
902
|
-
* Example: When I wait
|
|
903
|
-
* Example: When I wait
|
|
1005
|
+
|
|
1006
|
+
* Example #1: When I wait 1 second
|
|
1007
|
+
* Example #2: When I wait 5 seconds
|
|
1008
|
+
* Example #3: When we wait 3s
|
|
1009
|
+
* Example #4: And wait 2s
|
|
1010
|
+
* Example #5: And wait 2 seconds
|
|
1011
|
+
* Example #6: When we wait 1 second
|
|
1012
|
+
* Example #7: When we wait 5 seconds
|
|
1013
|
+
* Example #8: When we wait 4s
|
|
904
1014
|
*
|
|
905
1015
|
*/
|
|
906
|
-
When(/^(I|we)*
|
|
1016
|
+
When(/^(I |we )*wait (\d*)( second| seconds|s)?$/, function (pronounCase, number, withSecondWord) {
|
|
907
1017
|
var waitTime = number * 1000;
|
|
908
1018
|
return browser.pause(waitTime);
|
|
909
1019
|
});
|
|
@@ -911,10 +1021,17 @@ When(/^(I|we)* wait (\d*)( second)*(s)*$/, function (pronounCase, number, withWo
|
|
|
911
1021
|
/**
|
|
912
1022
|
* Wait a max number of seconds until the element present.
|
|
913
1023
|
*
|
|
914
|
-
* Example: When I wait max of
|
|
1024
|
+
* Example #1: When I wait max of 1 second
|
|
1025
|
+
* Example #2: When I wait max of 5 seconds
|
|
1026
|
+
* Example #3: When we wait max of 3s
|
|
1027
|
+
* Example #4: And wait max of 2s
|
|
1028
|
+
* Example #5: And wait max of 2 seconds
|
|
1029
|
+
* Example #6: When we wait max of 1 second
|
|
1030
|
+
* Example #7: When we wait max of 5 seconds
|
|
1031
|
+
* Example #8: When we wait max of 4s
|
|
915
1032
|
*
|
|
916
1033
|
*/
|
|
917
|
-
When(/^(I|we)*
|
|
1034
|
+
When(/^(I |we )*wait max of (\d*)( second| seconds|s)?$/, function (pronounCase, number, withSecondWord) {
|
|
918
1035
|
var waitTime = number * 1000;
|
|
919
1036
|
return browser.waitForElementPresent('body', waitTime);
|
|
920
1037
|
});
|
|
@@ -922,11 +1039,17 @@ When(/^(I|we)* wait max of (\d*)( second)*(s)*$/, function (pronounCase, number,
|
|
|
922
1039
|
/**
|
|
923
1040
|
* Wait a specific number of minutes.
|
|
924
1041
|
*
|
|
925
|
-
* Example: When I wait 1 minute
|
|
926
|
-
* Example: When I wait
|
|
1042
|
+
* Example #1: When I wait 1 minute
|
|
1043
|
+
* Example #2: When I wait 10 minutes
|
|
1044
|
+
* Example #3: When we wait 1m
|
|
1045
|
+
* Example #4: And wait 2s
|
|
1046
|
+
* Example #5: And wait 2 minutes
|
|
1047
|
+
* Example #6: When we wait 1 minute
|
|
1048
|
+
* Example #7: When we wait 10 minutes
|
|
1049
|
+
* Example #8: When we wait 2m
|
|
927
1050
|
*
|
|
928
1051
|
*/
|
|
929
|
-
When(/^(I|we)*
|
|
1052
|
+
When(/^(I |we )*wait (\d*)( minute| minutes|m)?$/, function (pronounCase, number, withMinuteWord) {
|
|
930
1053
|
var waitTime = number * 1000 * 60;
|
|
931
1054
|
return browser.pause(waitTime);
|
|
932
1055
|
});
|
|
@@ -934,10 +1057,17 @@ When(/^(I|we)* wait (\d*)( minute)*(m)*$/, function (pronounCase, number, withWo
|
|
|
934
1057
|
/**
|
|
935
1058
|
* Wait a max number of minutes until the element present.
|
|
936
1059
|
*
|
|
937
|
-
* Example: When I wait
|
|
1060
|
+
* Example #1: When I wait 1 minute
|
|
1061
|
+
* Example #2: When I wait 10 minutes
|
|
1062
|
+
* Example #3: When we wait 1m
|
|
1063
|
+
* Example #4: And wait 2s
|
|
1064
|
+
* Example #5: And wait 2 minutes
|
|
1065
|
+
* Example #6: When we wait 1 minute
|
|
1066
|
+
* Example #7: When we wait 10 minutes
|
|
1067
|
+
* Example #8: When we wait 2m
|
|
938
1068
|
*
|
|
939
1069
|
*/
|
|
940
|
-
When(/^(I|we)*
|
|
1070
|
+
When(/^(I |we )*wait max of (\d*)( minute| minutes|m)?$/, function (pronounCase, number, withMinuteWord) {
|
|
941
1071
|
var waitTime = number * 1000 * 60;
|
|
942
1072
|
return browser.waitForElementPresent('body', waitTime);
|
|
943
1073
|
});
|
|
@@ -945,16 +1075,19 @@ When(/^(I|we)* wait max of (\d*)( minute)*(m)*$/, function (pronounCase, number,
|
|
|
945
1075
|
/**
|
|
946
1076
|
* Wait until the page is loaded.
|
|
947
1077
|
*
|
|
948
|
-
* Example: When I wait until the page is loaded
|
|
1078
|
+
* Example #1: When I wait until the page is loaded
|
|
1079
|
+
* Example #1: When we wait until the page is loaded
|
|
1080
|
+
* Example #2: When wait until page loaded
|
|
949
1081
|
*
|
|
950
1082
|
*/
|
|
951
|
-
When(/^(I|we)*
|
|
1083
|
+
When(/^(I |we )*wait until( the)* page( is)* loaded*$/, function (pronounCase, theCase, withIs) {
|
|
952
1084
|
return browser.waitForElementPresent('body', 10000);
|
|
953
1085
|
});
|
|
1086
|
+
|
|
954
1087
|
/**
|
|
955
1088
|
* Checks, that the current page response status is equal the specified code.
|
|
956
1089
|
*
|
|
957
|
-
* Example: Then the response status code should be 200
|
|
1090
|
+
* Example #1: Then the response status code should be 200
|
|
958
1091
|
*
|
|
959
1092
|
*/
|
|
960
1093
|
Then(/^(the )*response status code should be (\d+)$/, function (theCase, expectedStatusCode) {
|
|
@@ -975,7 +1108,7 @@ Then(/^(the )*response status code should be (\d+)$/, function (theCase, expecte
|
|
|
975
1108
|
/**
|
|
976
1109
|
* Checks, that the current page response status is not equal the specified code.
|
|
977
1110
|
*
|
|
978
|
-
* Example: And the response status code should not be 404
|
|
1111
|
+
* Example #1: And the response status code should not be 404
|
|
979
1112
|
*
|
|
980
1113
|
*/
|
|
981
1114
|
Then(/^(the )*response status code should not be (\d+)$/, function ( theCase, expectedStatusCode) {
|
|
@@ -999,7 +1132,7 @@ Then(/^(the )*response status code should not be (\d+)$/, function ( theCase, ex
|
|
|
999
1132
|
* Example: Then I should see text matching "^T\w+" //pattern of word start with 'T'
|
|
1000
1133
|
*
|
|
1001
1134
|
*/
|
|
1002
|
-
Then(/^(I|we)*
|
|
1135
|
+
Then(/^(I |we )*should see text matching "([^"]*)?"$/, function (pronounCase, textPattern) {
|
|
1003
1136
|
browser.elements('css selector', 'body', function (elements) {
|
|
1004
1137
|
elements.value.forEach(function (elementsObj) {
|
|
1005
1138
|
return browser.assert.textMatches(elementsObj, textPattern);
|
|
@@ -1010,10 +1143,10 @@ Then(/^(I|we)* should see text matching "([^"]*)?"$/, function (pronounCase, tex
|
|
|
1010
1143
|
/**
|
|
1011
1144
|
* Checks, that page not contains text matching specified pattern.
|
|
1012
1145
|
*
|
|
1013
|
-
* Example: Then I should not see text matching "^O\w+" //pattern of word start with 'O'
|
|
1146
|
+
* Example #1: Then I should not see text matching "^O\w+" //pattern of word start with 'O'
|
|
1014
1147
|
*
|
|
1015
1148
|
*/
|
|
1016
|
-
Then(/^(I|we)*
|
|
1149
|
+
Then(/^(I |we )*should not see text matching "([^"]*)?"$/, function (pronounCase, textPattern) {
|
|
1017
1150
|
browser.elements('css selector', 'body', function (elements) {
|
|
1018
1151
|
elements.value.forEach(function (elementsObj) {
|
|
1019
1152
|
return browser.assert.not.textMatches(elementsObj, textPattern);
|
|
@@ -1024,27 +1157,25 @@ Then(/^(I|we)* should not see text matching "([^"]*)?"$/, function (pronounCase,
|
|
|
1024
1157
|
/**
|
|
1025
1158
|
* Checks, that page contains text matching specified pattern.
|
|
1026
1159
|
*
|
|
1027
|
-
* 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
|
|
1028
|
-
*
|
|
1160
|
+
* Example #1: 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
|
|
1161
|
+
* // pattern of DD/MM/YYYY or DD-MM-YYYY
|
|
1029
1162
|
*
|
|
1030
1163
|
*/
|
|
1031
|
-
Then(/^(I|we)*
|
|
1164
|
+
Then(/^(I |we )*should see text matching "([^"]*)?" in( the)* "([^"]*)?" element$/, function (pronounCase, textPattern, theCase, element) {
|
|
1032
1165
|
return this.shouldSeePattern = function (browser) {
|
|
1033
1166
|
browser.assert.textMatches(element, textPattern);
|
|
1034
1167
|
};
|
|
1035
1168
|
});
|
|
1036
1169
|
|
|
1037
1170
|
/**
|
|
1038
|
-
* Checks, that page
|
|
1171
|
+
* Checks, that page dose not contain text matching specified pattern.
|
|
1039
1172
|
*
|
|
1040
|
-
* 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
|
|
1041
|
-
*
|
|
1173
|
+
* Example #1: 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
|
|
1174
|
+
* // pattern of DD/MM/YYYY or DD-MM-YYYY
|
|
1042
1175
|
*
|
|
1043
1176
|
*/
|
|
1044
|
-
Then(/^(I|we)*
|
|
1045
|
-
return
|
|
1046
|
-
browser.assert.not.textMatches(element, textPattern);
|
|
1047
|
-
};
|
|
1177
|
+
Then(/^(I |we )*should not see text matching "([^"]*)?" in( the)* "([^"]*)?" element$/, function (pronounCase, textPattern, theCase, element) {
|
|
1178
|
+
return browser.assert.not.textMatches(element, textPattern);
|
|
1048
1179
|
});
|
|
1049
1180
|
|
|
1050
1181
|
/**
|
|
@@ -1075,7 +1206,7 @@ Then(/^(the )*url should not match "([^"]*)?"$/, function (theCase, pattern) {
|
|
|
1075
1206
|
* Example #3: And we scroll down 500
|
|
1076
1207
|
* Example #4: When scrolling down 1200
|
|
1077
1208
|
*/
|
|
1078
|
-
When(/^(I|we
|
|
1209
|
+
When(/^(I scroll|we scroll|scrolling)? down( ([^"]*)?)*$/, function(pronounCase, value) {
|
|
1079
1210
|
// Default scroll value
|
|
1080
1211
|
let scrollValue = 350;
|
|
1081
1212
|
|
|
@@ -1108,7 +1239,7 @@ When(/^(I|we)? (scroll|scrolling) down( ([^"]*)?)*$/, function(pronounCase, scro
|
|
|
1108
1239
|
* Example #4: When scrolling up 750
|
|
1109
1240
|
*
|
|
1110
1241
|
*/
|
|
1111
|
-
When(/^(I|we
|
|
1242
|
+
When(/^(I scroll|we scroll|scrolling)? up( ([^"]*)?)*$/, function(pronounCase, value) {
|
|
1112
1243
|
// Parse and validate the scroll value
|
|
1113
1244
|
let scrollValue = 350; // default value
|
|
1114
1245
|
|
|
@@ -1140,7 +1271,7 @@ When(/^(I|we)? (scroll|scrolling) up( ([^"]*)?)*$/, function(pronounCase, scroll
|
|
|
1140
1271
|
* Example #2: And we scrolling to the top
|
|
1141
1272
|
* Example #3: When scrolling to the top of the page
|
|
1142
1273
|
*/
|
|
1143
|
-
When(/^(I|we
|
|
1274
|
+
When(/^(I scroll|we scroll|scrolling)? to( the)* top( of the page)*$/, function(pronounCase, theCase, pageCase) {
|
|
1144
1275
|
return browser.executeScript('document.documentElement.scrollTop = 0;');
|
|
1145
1276
|
});
|
|
1146
1277
|
|
|
@@ -1151,7 +1282,7 @@ When(/^(I|we)* (scroll|scrolling) to( the)* top( of the page)*$/, function(prono
|
|
|
1151
1282
|
* Example #2: And we scroll to bottom
|
|
1152
1283
|
* Example #3: When scrolling to the bottom of the page
|
|
1153
1284
|
*/
|
|
1154
|
-
When(/^(I|we
|
|
1285
|
+
When(/^(I scroll|we scroll|scrolling)? to( the)* bottom( of the page)*$/, function(pronounCase, theCase, pageCase) {
|
|
1155
1286
|
return browser.executeScript('window.scrollTo(0, document.body.scrollHeight);');
|
|
1156
1287
|
});
|
|
1157
1288
|
|
|
@@ -1162,7 +1293,7 @@ When(/^(I|we)* (scroll|scrolling) to( the)* bottom( of the page)*$/, function(pr
|
|
|
1162
1293
|
* Example #2: And we scroll to top of "#sidebar"
|
|
1163
1294
|
* Example #3: When scrolling to top of "#main-container"
|
|
1164
1295
|
*/
|
|
1165
|
-
When(/^(I|we
|
|
1296
|
+
When(/^(I scroll|we scroll|scrolling)? to top of "([^"]*)"$/, function(pronounCase, selector) {
|
|
1166
1297
|
// Validate selector
|
|
1167
1298
|
if (!selector || selector.trim() === '') {
|
|
1168
1299
|
throw new Error('Selector cannot be empty. Please provide a valid CSS selector.');
|
|
@@ -1203,7 +1334,7 @@ When(/^(I|we)* (scroll|scrolling) to top of "([^"]*)"$/, function(pronounCase, s
|
|
|
1203
1334
|
* Example #2: And we scrolling to bottom of "#sidebar"
|
|
1204
1335
|
* Example #3: When scrolling to bottom of "#main-container"
|
|
1205
1336
|
*/
|
|
1206
|
-
When(/^(I|we
|
|
1337
|
+
When(/^(I scroll|we scroll|scrolling)? to bottom of "([^"]*)"$/, function(pronounCase, selector) {
|
|
1207
1338
|
// Validate selector
|
|
1208
1339
|
if (!selector || selector.trim() === '') {
|
|
1209
1340
|
throw new Error('Selector cannot be empty. Please provide a valid CSS selector.');
|
|
@@ -1235,4 +1366,174 @@ When(/^(I|we)* (scroll|scrolling) to bottom of "([^"]*)"$/, function(pronounCase
|
|
|
1235
1366
|
} catch (error) {
|
|
1236
1367
|
throw new Error(`Failed to scroll to bottom of element "${selector}": ${error.message}`);
|
|
1237
1368
|
}
|
|
1238
|
-
});
|
|
1369
|
+
});
|
|
1370
|
+
|
|
1371
|
+
/**
|
|
1372
|
+
* Scrolls right the page by a custom number of pixels specified by the user.
|
|
1373
|
+
*
|
|
1374
|
+
* Example #1: And I scroll right
|
|
1375
|
+
* Example #2: When I scroll right 1000
|
|
1376
|
+
* Example #3: And we scrolling right 300
|
|
1377
|
+
* Example #4: When scrolling right 750
|
|
1378
|
+
*
|
|
1379
|
+
*/
|
|
1380
|
+
When(/^(I scroll|we scroll|scrolling)? right( ([^"]*)?)*$/, function(pronounCase, value) {
|
|
1381
|
+
// Parse and validate the scroll value
|
|
1382
|
+
let scrollValue = 350; // default value
|
|
1383
|
+
|
|
1384
|
+
if (value !== null) {
|
|
1385
|
+
scrollValue = parseInt(String(value).trim(), 10);
|
|
1386
|
+
|
|
1387
|
+
// Validate the parsed value
|
|
1388
|
+
if (isNaN(scrollValue)) {
|
|
1389
|
+
throw new Error(`Invalid scroll value: "${value}". Expected a number.`);
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
if (scrollValue < 0) {
|
|
1393
|
+
throw new Error(`Scroll right value must be positive. Received: ${scrollValue}`);
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
if (scrollValue > 10000) {
|
|
1397
|
+
console.warn(`Large scroll value detected: ${scrollValue}px. Consider if this is intentional.`);
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
// Make the value negative for scrolling right
|
|
1402
|
+
return browser.executeScript(`window.scrollBy( ${scrollValue}, 0);`);
|
|
1403
|
+
});
|
|
1404
|
+
|
|
1405
|
+
/**
|
|
1406
|
+
* Scrolls left the page by a custom number of pixels specified by the user.
|
|
1407
|
+
*
|
|
1408
|
+
* Example #1: And I scroll left
|
|
1409
|
+
* Example #2: When I scroll left 800
|
|
1410
|
+
* Example #3: And we scroll left 500
|
|
1411
|
+
* Example #4: When scrolling left 1200
|
|
1412
|
+
*/
|
|
1413
|
+
When(/^(I scroll|we scroll|scrolling)? left( ([^"]*)?)*$/, function(pronounCase, value) {
|
|
1414
|
+
// Default scroll value
|
|
1415
|
+
let scrollValue = 350;
|
|
1416
|
+
|
|
1417
|
+
if (value !== null) {
|
|
1418
|
+
scrollValue = parseInt(String(value).trim(), 10);
|
|
1419
|
+
|
|
1420
|
+
// Validate the parsed value
|
|
1421
|
+
if (isNaN(scrollValue)) {
|
|
1422
|
+
throw new Error(`Invalid scroll value: "${value}". Expected a number.`);
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
if (scrollValue < 0) {
|
|
1426
|
+
throw new Error(`Scroll left value must be positive. Received: ${scrollValue}`);
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
if (scrollValue > 10000) {
|
|
1430
|
+
console.warn(`Large scroll value detected: ${scrollValue}px. Consider if this is intentional.`);
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
return browser.executeScript(`window.scrollBy( -${scrollValue},0 );`);
|
|
1435
|
+
});
|
|
1436
|
+
|
|
1437
|
+
/**
|
|
1438
|
+
* Scrolls to the very start of the current page, resetting the scroll position to zero.
|
|
1439
|
+
*
|
|
1440
|
+
* Example #1: When I scroll to start
|
|
1441
|
+
* Example #2: And we scrolling to the start
|
|
1442
|
+
* Example #3: When scrolling to the start of the page
|
|
1443
|
+
*/
|
|
1444
|
+
When(/^(I scroll|we scroll|scrolling)? to( the)* start( of the page)*$/, function(pronounCase, theCase, pageCase) {
|
|
1445
|
+
return browser.executeScript('window.scrollTo(0, window.scrollY);');
|
|
1446
|
+
});
|
|
1447
|
+
|
|
1448
|
+
/**
|
|
1449
|
+
* Scrolls to the end of the current page using the full document height.
|
|
1450
|
+
*
|
|
1451
|
+
* Example #1: When I scroll to the end
|
|
1452
|
+
* Example #2: And we scroll to end
|
|
1453
|
+
* Example #3: When scrolling to the end of the page
|
|
1454
|
+
*/
|
|
1455
|
+
When(/^(I scroll|we scroll|scrolling)? to( the)* end( of the page)*$/, function(pronounCase, theCase, pageCase) {
|
|
1456
|
+
return browser.executeScript('window.scrollTo(document.body.scrollWidth, window.scrollY);');
|
|
1457
|
+
});
|
|
1458
|
+
|
|
1459
|
+
/**
|
|
1460
|
+
* Scrolls to the start of a specific element identified by a CSS selector, resetting its scroll position to zero.
|
|
1461
|
+
*
|
|
1462
|
+
* Example #1: When I scroll to start of "#off-canvas"
|
|
1463
|
+
* Example #2: And we scroll to start of "#sidebar"
|
|
1464
|
+
* Example #3: When scrolling to start of "#main-container"
|
|
1465
|
+
*/
|
|
1466
|
+
When(/^(I scroll|we scroll|scrolling)? to start of "([^"]*)"$/, function(pronounCase, selector) {
|
|
1467
|
+
// Validate selector
|
|
1468
|
+
if (!selector || selector.trim() === '') {
|
|
1469
|
+
throw new Error('Selector cannot be empty. Please provide a valid CSS selector.');
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
// Validate selector format (basic check)
|
|
1473
|
+
if (selector.includes('"') || selector.includes("'")) {
|
|
1474
|
+
throw new Error(`Invalid selector format: "${selector}". Selector should not contain quotes.`);
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
try {
|
|
1478
|
+
// Check if element exists before scrolling
|
|
1479
|
+
const elementExists = browser.executeScript(`
|
|
1480
|
+
return document.querySelector("${selector}") !== null;
|
|
1481
|
+
`);
|
|
1482
|
+
|
|
1483
|
+
if (!elementExists) {
|
|
1484
|
+
throw new Error(`Element with selector "${selector}" not found.`);
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
browser.executeScript(`
|
|
1488
|
+
const element = document.querySelector("${selector}");
|
|
1489
|
+
if (element) {
|
|
1490
|
+
element.scrollTop = 0;
|
|
1491
|
+
}
|
|
1492
|
+
`);
|
|
1493
|
+
|
|
1494
|
+
return browser.pause(2000);
|
|
1495
|
+
} catch (error) {
|
|
1496
|
+
throw new Error(`Failed to scroll to top of element "${selector}": ${error.message}`);
|
|
1497
|
+
}
|
|
1498
|
+
});
|
|
1499
|
+
|
|
1500
|
+
/**
|
|
1501
|
+
* Scrolls to the end of a specific element identified by a CSS selector, moving to its maximum scroll height.
|
|
1502
|
+
*
|
|
1503
|
+
* Example #1: When I scroll to end of "#off-canvas"
|
|
1504
|
+
* Example #2: And we scrolling to end of "#sidebar"
|
|
1505
|
+
* Example #3: When scrolling to end of "#main-container"
|
|
1506
|
+
*/
|
|
1507
|
+
When(/^(I scroll|we scroll|scrolling)? to end of "([^"]*)"$/, function(pronounCase, selector) {
|
|
1508
|
+
// Validate selector
|
|
1509
|
+
if (!selector || selector.trim() === '') {
|
|
1510
|
+
throw new Error('Selector cannot be empty. Please provide a valid CSS selector.');
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
// Validate selector format (basic check)
|
|
1514
|
+
if (selector.includes('"') || selector.includes("'")) {
|
|
1515
|
+
throw new Error(`Invalid selector format: "${selector}". Selector should not contain quotes.`);
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
try {
|
|
1519
|
+
// Check if element exists before scrolling
|
|
1520
|
+
const elementExists = browser.executeScript(`
|
|
1521
|
+
return document.querySelector("${selector}") !== null;
|
|
1522
|
+
`);
|
|
1523
|
+
|
|
1524
|
+
if (!elementExists) {
|
|
1525
|
+
throw new Error(`Element with selector "${selector}" not found.`);
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
browser.executeScript(`
|
|
1529
|
+
const element = document.querySelector("${selector}");
|
|
1530
|
+
if (element) {
|
|
1531
|
+
element.scrollTop = element.scrollWidth;
|
|
1532
|
+
}
|
|
1533
|
+
`);
|
|
1534
|
+
|
|
1535
|
+
return browser.pause(2000);
|
|
1536
|
+
} catch (error) {
|
|
1537
|
+
throw new Error(`Failed to scroll to bottom of element "${selector}": ${error.message}`);
|
|
1538
|
+
}
|
|
1539
|
+
});
|