webship-js 1.0.40 → 1.0.41
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/assets/config_templates/circleci-linux-chrome.conf.js +10 -1
- package/assets/config_templates/github-linux-chrome.conf.js +10 -1
- package/lib/custom-hooks/before-after.js +30 -0
- package/nightwatch.conf.js +12 -3
- package/package.json +1 -1
- package/tests/features/test--when--i-attach-file-to-feild.feature +1 -2
- package/tests/step-definitions/webship.js +252 -151
|
@@ -19,7 +19,16 @@ module.exports = {
|
|
|
19
19
|
parallel: 2,
|
|
20
20
|
},
|
|
21
21
|
},
|
|
22
|
-
|
|
22
|
+
globals: {
|
|
23
|
+
assets_folder : "/test/assets/",
|
|
24
|
+
minimum_wait_time: {
|
|
25
|
+
page: 3000,
|
|
26
|
+
before_scenario: 0,
|
|
27
|
+
after_scenario: 0,
|
|
28
|
+
before_step: 0,
|
|
29
|
+
after_step: 1000
|
|
30
|
+
}
|
|
31
|
+
},
|
|
23
32
|
test_settings: {
|
|
24
33
|
default: {
|
|
25
34
|
launch_url: 'http://localhost:8080/',
|
|
@@ -30,7 +30,16 @@ module.exports = {
|
|
|
30
30
|
},
|
|
31
31
|
|
|
32
32
|
},
|
|
33
|
-
|
|
33
|
+
globals: {
|
|
34
|
+
assets_folder : "/test/assets/",
|
|
35
|
+
minimum_wait_time: {
|
|
36
|
+
page: 3000,
|
|
37
|
+
before_scenario: 0,
|
|
38
|
+
after_scenario: 0,
|
|
39
|
+
before_step: 0,
|
|
40
|
+
after_step: 1000
|
|
41
|
+
}
|
|
42
|
+
},
|
|
34
43
|
test_settings: {
|
|
35
44
|
default: {
|
|
36
45
|
launch_url: 'http://localhost:8080/',
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const {Before, After, BeforeStep, AfterStep} = require('@cucumber/cucumber');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Safely pauses based on global config.
|
|
5
|
+
* Handles case where browser or globals may be undefined.
|
|
6
|
+
* @param {string} key
|
|
7
|
+
*/
|
|
8
|
+
function safePause(key) {
|
|
9
|
+
const time = (global.browser?.globals?.minimum_wait_time?.[key]) || 0;
|
|
10
|
+
if (time > 0 && global.browser?.pause) {
|
|
11
|
+
global.browser.pause(time);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Register hooks
|
|
16
|
+
Before(function () {
|
|
17
|
+
safePause('before_scenario');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
After(function () {
|
|
21
|
+
safePause('after_scenario');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
BeforeStep(function () {
|
|
25
|
+
safePause('before_step');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
AfterStep(function () {
|
|
29
|
+
safePause('after_step');
|
|
30
|
+
});
|
package/nightwatch.conf.js
CHANGED
|
@@ -4,7 +4,7 @@ require('events').EventEmitter.defaultMaxListeners = 1000;
|
|
|
4
4
|
module.exports = {
|
|
5
5
|
// An array of folders (excluding subfolders) where your tests are located;
|
|
6
6
|
// if this is not specified, the test source must be passed as the second argument to the test runner.
|
|
7
|
-
src_folders: ['tests/step-definitions'],
|
|
7
|
+
src_folders: ['./tests/step-definitions'],
|
|
8
8
|
|
|
9
9
|
// See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
|
|
10
10
|
custom_commands_path: './lib/custom-commands',
|
|
@@ -15,12 +15,21 @@ module.exports = {
|
|
|
15
15
|
test_runner: {
|
|
16
16
|
type: 'cucumber',
|
|
17
17
|
options: {
|
|
18
|
-
feature_path: 'tests/features/*.feature',
|
|
18
|
+
feature_path: './tests/features/*.feature',
|
|
19
19
|
additional_config: '',
|
|
20
20
|
parallel: 1,
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
|
-
|
|
23
|
+
globals: {
|
|
24
|
+
assets_folder : "/test/assets/",
|
|
25
|
+
min_wait_time: {
|
|
26
|
+
page : 3000,
|
|
27
|
+
before_scenario : 0,
|
|
28
|
+
after_scenario : 0,
|
|
29
|
+
before_step : 0,
|
|
30
|
+
after_step : 1000
|
|
31
|
+
}
|
|
32
|
+
},
|
|
24
33
|
test_settings: {
|
|
25
34
|
default: {
|
|
26
35
|
launch_url: 'http://localhost:8080',
|
package/package.json
CHANGED
|
@@ -6,5 +6,4 @@ Feature: An example of checking the attachment of a file to a field
|
|
|
6
6
|
Given I am on "/test--when--i-attach-file-to-feild.html"
|
|
7
7
|
When I attach the file "webshipco.png" to "#fileUpload"
|
|
8
8
|
And I press "Submit" by attr
|
|
9
|
-
And I wait 2 second
|
|
10
|
-
Then I should see "webshipco.png"
|
|
9
|
+
And I wait 2 second
|
|
@@ -1,73 +1,118 @@
|
|
|
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
|
+
require('../../lib/custom-hooks/before-after');
|
|
4
5
|
|
|
5
6
|
const axios = require('axios');
|
|
6
|
-
|
|
7
|
+
const path = require('path');
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Opens homepage.
|
|
10
11
|
*
|
|
11
|
-
* Example: Given I am on homepage
|
|
12
|
-
* Example: Given I am on the homepage
|
|
12
|
+
* Example #1: Given I am on homepage
|
|
13
|
+
* Example #2: Given I am on the homepage
|
|
14
|
+
* Example #2: Given I am on frontpage
|
|
15
|
+
* Example #3: Given I am on the frontpage
|
|
16
|
+
* Example #4: Given we are on homepage
|
|
17
|
+
* Example #5: Given on the homepage
|
|
18
|
+
* Example #6: Given on homepage
|
|
19
|
+
* Example #7: Given we are on the frontpage
|
|
20
|
+
* Example #8: Given on frontpage
|
|
21
|
+
*
|
|
13
22
|
*
|
|
14
23
|
*/
|
|
15
|
-
Given(/^(I am|we are)
|
|
16
|
-
|
|
24
|
+
Given(/^(I am |we are )?on( the)* (homepage|frontpage)$/, function (pronounCase, theCase, pageCase) {
|
|
25
|
+
browser.url(browser.launch_url);
|
|
26
|
+
let defaultTime = 3000;
|
|
27
|
+
if (browser.globals && browser.globals.minimum_wait_time && browser.globals.minimum_wait_time.page) {
|
|
28
|
+
defaultTime = browser.globals.minimum_wait_time.page;
|
|
29
|
+
}
|
|
30
|
+
return browser.waitForElementPresent('body', defaultTime);
|
|
17
31
|
});
|
|
18
32
|
|
|
19
33
|
/**
|
|
20
34
|
* Open specific page.
|
|
21
35
|
*
|
|
22
|
-
* Example: Given I am on "about-us.html"
|
|
36
|
+
* Example #1: Given I am on "/about-us.html"
|
|
37
|
+
* Example #2: Given we are on "/about-us.html"
|
|
38
|
+
* Example #3: Given I am on the "/about-us.html" page
|
|
39
|
+
* Example #4: Given we are on the "/about-us.html" page
|
|
40
|
+
* Example #5: Given on "/about-us.html"
|
|
41
|
+
* Example #6: Given on the "/about-us.html" page
|
|
23
42
|
*
|
|
24
43
|
*/
|
|
25
|
-
Given(/^(I am|we are)
|
|
26
|
-
|
|
44
|
+
Given(/^(I am |we are )*on( the)* "([^"]*)?"( page)*$/, function (pronounCase, theCase, url, pageCase) {
|
|
45
|
+
browser.url(browser.launch_url + url);
|
|
46
|
+
let defaultTime = 3000;
|
|
47
|
+
if (browser.globals && browser.globals.minimum_wait_time && browser.globals.minimum_wait_time.page) {
|
|
48
|
+
defaultTime = browser.globals.minimum_wait_time.page;
|
|
49
|
+
}
|
|
50
|
+
return browser.waitForElementPresent('body', defaultTime);
|
|
27
51
|
});
|
|
28
52
|
|
|
29
53
|
/**
|
|
30
54
|
* Go to homepage.
|
|
31
55
|
*
|
|
32
|
-
* Example: When I go to homepage
|
|
33
|
-
* Example: When I go to the homepage
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
56
|
+
* Example #1: When I go to homepage
|
|
57
|
+
* Example #2: When I go to the homepage
|
|
58
|
+
* Example #3: When I navigate to the homepage
|
|
59
|
+
* Example #4: When navigating to the homepage
|
|
60
|
+
* Example #5: When navigating to homepage
|
|
61
|
+
* Example #6: When navigating to the frontpage
|
|
62
|
+
* Example #7: When we go to the homepage
|
|
63
|
+
* Example #8: When we navigate to the homepage
|
|
64
|
+
*
|
|
65
|
+
*/
|
|
66
|
+
When(/^(I go |I navigate |we go |we navigate |navigating )?to( the)* (homepage|frontpage)$/, function (pronounCase, theCase, pageCase) {
|
|
67
|
+
browser.url(browser.launch_url);
|
|
68
|
+
let defaultTime = 3000;
|
|
69
|
+
if (browser.globals && browser.globals.minimum_wait_time && browser.globals.minimum_wait_time.page) {
|
|
70
|
+
defaultTime = browser.globals.minimum_wait_time.page;
|
|
71
|
+
}
|
|
72
|
+
return browser.waitForElementPresent('body', defaultTime);
|
|
38
73
|
});
|
|
39
74
|
|
|
40
75
|
/**
|
|
41
76
|
* Go to specific page.
|
|
42
77
|
*
|
|
43
|
-
* Example: When I go to "contact-us.html"
|
|
78
|
+
* Example #1: When I go to "/contact-us.html"
|
|
79
|
+
* Example #2: When I go to "/user/login"
|
|
80
|
+
* Example #3: When I navigate to "/admin/dashboard"
|
|
81
|
+
* Example #4: When navigating to "/products"
|
|
82
|
+
* Example #7: When we go to "/products"
|
|
83
|
+
* Example #8: When we navigate to "/terms"
|
|
44
84
|
*
|
|
45
85
|
*/
|
|
46
|
-
When(/^(I|we
|
|
47
|
-
|
|
86
|
+
When(/^(I go |I navigate |we go |we navigate |navigating )?to "([^"]*)?"$/, function (pronounCase, url) {
|
|
87
|
+
browser.url(browser.launch_url + url);
|
|
88
|
+
let defaultTime = 3000;
|
|
89
|
+
if (browser.globals && browser.globals.minimum_wait_time && browser.globals.minimum_wait_time.page) {
|
|
90
|
+
defaultTime = browser.globals.minimum_wait_time.page;
|
|
91
|
+
}
|
|
92
|
+
return browser.waitForElementPresent('body', defaultTime);
|
|
48
93
|
});
|
|
49
94
|
|
|
50
95
|
/**
|
|
51
96
|
* Asserting a text in the page.
|
|
52
97
|
*
|
|
53
|
-
* Example:
|
|
54
|
-
*
|
|
98
|
+
* Example #1: Then I should see "Welcome"
|
|
99
|
+
* Example #2: Then we should see "Your accounts for the group is public"
|
|
55
100
|
*
|
|
56
101
|
*/
|
|
57
|
-
Then(/^(I|we)*
|
|
102
|
+
Then(/^(I |we )*should see "([^"]*)?"$/, function (pronounCase, expectedText) {
|
|
58
103
|
return this.shouldSee = function (browser) {
|
|
59
104
|
browser.assert.textContains("html", expectedText);
|
|
60
105
|
};
|
|
61
106
|
});
|
|
62
107
|
|
|
63
108
|
/**
|
|
64
|
-
* Asserting a text
|
|
109
|
+
* Asserting a text in the page.
|
|
65
110
|
*
|
|
66
|
-
* Example:
|
|
67
|
-
*
|
|
111
|
+
* Example #1: Then I should not see "Access denied"
|
|
112
|
+
* Example #2: Then we should not see "Edit layout"
|
|
68
113
|
*
|
|
69
114
|
*/
|
|
70
|
-
Then(/^(I|we)*
|
|
115
|
+
Then(/^(I |we )*should not see "([^"]*)?"$/, function (pronounCase, expectedText) {
|
|
71
116
|
return this.shouldSee = function (browser) {
|
|
72
117
|
browser.assert.not.textContains("html", expectedText);
|
|
73
118
|
};
|
|
@@ -79,7 +124,7 @@ Then(/^(I|we)* should not see "([^"]*)?"$/, function (pronounCase, expectedText)
|
|
|
79
124
|
* Example: When I move forward one page
|
|
80
125
|
*
|
|
81
126
|
*/
|
|
82
|
-
When(/^(I|we)*
|
|
127
|
+
When(/^(I |we )*move forward one page$/, function (pronounCase) {
|
|
83
128
|
return browser.forward();
|
|
84
129
|
});
|
|
85
130
|
|
|
@@ -89,7 +134,7 @@ When(/^(I|we)* move forward one page$/, function (pronounCase) {
|
|
|
89
134
|
* Example: When I move backward one page
|
|
90
135
|
*
|
|
91
136
|
*/
|
|
92
|
-
When(/^(I|we)*
|
|
137
|
+
When(/^(I |we )*move backward one page$/, function (pronounCase) {
|
|
93
138
|
return browser.back();
|
|
94
139
|
});
|
|
95
140
|
|
|
@@ -101,7 +146,7 @@ When(/^(I|we)* move backward one page$/, function (pronounCase) {
|
|
|
101
146
|
* Example: And I press the "Save as" button
|
|
102
147
|
*
|
|
103
148
|
*/
|
|
104
|
-
When(/^(I|we)*
|
|
149
|
+
When(/^(I |we )*press( the)* "([^"]*)?"( button)*$/, function (pronounCase, theCase, element, buttonCase) {
|
|
105
150
|
browser.click("[value='" + element +"']");
|
|
106
151
|
});
|
|
107
152
|
|
|
@@ -115,7 +160,7 @@ When(/^(I|we)* press( the)* "([^"]*)?"( button)*$/, function (pronounCase, theCa
|
|
|
115
160
|
* Example: And I press "save-name" by "data-selector" attr
|
|
116
161
|
*
|
|
117
162
|
*/
|
|
118
|
-
When(/^(I|we)*
|
|
163
|
+
When(/^(I |we )*press "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronounCase, attrValue, itsCase, attr, attrCase) {
|
|
119
164
|
|
|
120
165
|
const hasASpace = attrValue.indexOf(' ');
|
|
121
166
|
var selector = '';
|
|
@@ -143,20 +188,20 @@ When(/^(I|we)* press "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, func
|
|
|
143
188
|
* Example: And I click "aboutUs"
|
|
144
189
|
*
|
|
145
190
|
*/
|
|
146
|
-
When(/^(I|we)*
|
|
191
|
+
When(/^(I |we )*click "([^"]*)?"$/, function (pronounCase, item) {
|
|
147
192
|
return browser.click("link text", item);
|
|
148
193
|
});
|
|
149
194
|
|
|
150
195
|
/**
|
|
151
196
|
* Click Link with specified element.
|
|
152
197
|
*
|
|
153
|
-
* Example: When I click "#
|
|
154
|
-
* Example: When I click "
|
|
155
|
-
* Example: And I click "
|
|
156
|
-
* Example: And I click "
|
|
198
|
+
* Example: When I click "#about-us-id" by attr
|
|
199
|
+
* Example: When I click "data-selector-about" by attribute
|
|
200
|
+
* Example: And I click "about-us-css" by "class" attr
|
|
201
|
+
* Example: And I click "about-us-id" by its "id" attribute
|
|
157
202
|
*
|
|
158
203
|
*/
|
|
159
|
-
When(/^(I|we)*
|
|
204
|
+
When(/^(I |we )*click "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronounCase, attrValue, itsCase, attr, attrCase) {
|
|
160
205
|
|
|
161
206
|
const hasASpace = attrValue.indexOf(' ');
|
|
162
207
|
var selector = '';
|
|
@@ -181,23 +226,13 @@ When(/^(I|we)* click "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, func
|
|
|
181
226
|
/**
|
|
182
227
|
* Reloads current page.
|
|
183
228
|
*
|
|
184
|
-
* Example: When I reload
|
|
185
|
-
* Example:
|
|
186
|
-
*
|
|
187
|
-
|
|
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
|
|
229
|
+
* Example #1: When I reload
|
|
230
|
+
* Example #2: And I reload the page
|
|
231
|
+
* Example #3: And we reload page
|
|
232
|
+
* Example #4: And we reload the page
|
|
198
233
|
*
|
|
199
234
|
*/
|
|
200
|
-
When(/^(I|we)*
|
|
235
|
+
When(/^(I |we )*reload( the)*( page)*$/, function (pronounCase, theCase, pageCase) {
|
|
201
236
|
return browser.refresh(browser.getCurrentUrl());
|
|
202
237
|
});
|
|
203
238
|
|
|
@@ -207,7 +242,7 @@ When(/^(I|we)* reload( the)* page$/, function (pronounCase, theCase) {
|
|
|
207
242
|
* Example: When I fill in "Username" with "John Smith"
|
|
208
243
|
*
|
|
209
244
|
*/
|
|
210
|
-
When(/^(I|we)*
|
|
245
|
+
When(/^(I |we )*fill in "([^"]*)?" with "([^"]*)?"$/, function (pronounCase, field, value) {
|
|
211
246
|
const elementField = browser.element.findByText(field, { exact: true });
|
|
212
247
|
browser.getAttribute(elementField, 'for', function (eleAttribute) {
|
|
213
248
|
return browser.setValue('#' + eleAttribute.value, value);
|
|
@@ -223,7 +258,7 @@ When(/^(I|we)* fill in "([^"]*)?" with "([^"]*)?"$/, function (pronounCase, fiel
|
|
|
223
258
|
* Example: And I fill in "Your full name" with "John Smith" by its "placeholder" attribute
|
|
224
259
|
*
|
|
225
260
|
*/
|
|
226
|
-
When(/^(I|we)*
|
|
261
|
+
When(/^(I |we )*fill in "([^"]*)?" with "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronounCase, attrValue, txtValue, itsCase, attr, attrCase) {
|
|
227
262
|
|
|
228
263
|
const hasASpace = attrValue.indexOf(' ');
|
|
229
264
|
var selector = '';
|
|
@@ -251,7 +286,7 @@ When(/^(I|we)* fill in "([^"]*)?" with "([^"]*)?" by( its)*( "([^"]*)?")* (attri
|
|
|
251
286
|
* Example: When I fill in "Username" with:
|
|
252
287
|
*
|
|
253
288
|
*/
|
|
254
|
-
When(/^(I|we)*
|
|
289
|
+
When(/^(I |we )*fill in "([^"]*)?" with:$/, function (pronounCase, field) {
|
|
255
290
|
const elementField = browser.element.findByText(field, { exact: true });
|
|
256
291
|
browser.getAttribute(elementField, 'for', function (eleAttribute) {
|
|
257
292
|
return browser.setValue('#' + eleAttribute.value, '');
|
|
@@ -267,7 +302,7 @@ When(/^(I|we)* fill in "([^"]*)?" with:$/, function (pronounCase, field) {
|
|
|
267
302
|
* Example: And I fill in "Your full name" with: by its "placeholder" attribute
|
|
268
303
|
*
|
|
269
304
|
*/
|
|
270
|
-
When(/^(I|we)*
|
|
305
|
+
When(/^(I |we )*fill in "([^"]*)?" with: by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronounCase, attrValue , itsCase, attr, attrCase) {
|
|
271
306
|
|
|
272
307
|
const hasASpace = attrValue.indexOf(' ');
|
|
273
308
|
var selector = '';
|
|
@@ -291,10 +326,11 @@ When(/^(I|we)* fill in "([^"]*)?" with: by( its)*( "([^"]*)?")* (attribute|attr)
|
|
|
291
326
|
/**
|
|
292
327
|
* Fill in value for input type text by its Label.
|
|
293
328
|
*
|
|
294
|
-
* Example: When I fill in "jon-smith" for "Username"
|
|
329
|
+
* Example #1: When I fill in "jon-smith" for "Username"
|
|
330
|
+
* Example #2: When we fill in "Testing" for "Organization options"
|
|
295
331
|
*
|
|
296
332
|
*/
|
|
297
|
-
When(/^(I|we)*
|
|
333
|
+
When(/^(I |we )*fill in "([^"]*)?" for "([^"]*)?"$/, function (pronounCase, value, field) {
|
|
298
334
|
const elementField = browser.element.findByText(field, { exact: true });
|
|
299
335
|
browser.getAttribute(elementField, 'for', function (eleAttribute) {
|
|
300
336
|
return browser.setValue('#' + eleAttribute.value, value);
|
|
@@ -304,13 +340,13 @@ When(/^(I|we)* fill in "([^"]*)?" for "([^"]*)?"$/, function (pronounCase, value
|
|
|
304
340
|
/**
|
|
305
341
|
* Fill in value for input type text by its attribute.
|
|
306
342
|
*
|
|
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
|
|
343
|
+
* Example #1: When I fill in "John Smith" for "#uname" by attr
|
|
344
|
+
* Example #2: When I fill in "John Smith" for "uname" by attr
|
|
345
|
+
* Example #3: And I fill in "1234" for "password" by "class" attr
|
|
346
|
+
* Example #4: And I fill in "John Smith" for "Your full name" by its "placeholder" attribute
|
|
311
347
|
*
|
|
312
348
|
*/
|
|
313
|
-
When(/^(I|we)*
|
|
349
|
+
When(/^(I |we )*fill in "([^"]*)?" for "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronounCase, txtValue, attrValue, itsCase, attr, attrCase) {
|
|
314
350
|
|
|
315
351
|
const hasASpace = attrValue.indexOf(' ');
|
|
316
352
|
var selector = '';
|
|
@@ -340,7 +376,7 @@ When(/^(I|we)* fill in "([^"]*)?" for "([^"]*)?" by( its)*( "([^"]*)?")* (attrib
|
|
|
340
376
|
* | Password | 1234 |
|
|
341
377
|
*/
|
|
342
378
|
|
|
343
|
-
When(/^(I|we)*
|
|
379
|
+
When(/^(I |we )*fill in( the)* following:$/, function (pronounCase, theCase, table) {
|
|
344
380
|
|
|
345
381
|
var elementField = browser.element.findByText(table.rawTable[0][0], { exact: true });
|
|
346
382
|
browser.getAttribute(elementField, 'for', function (eleAttribute) {
|
|
@@ -360,15 +396,15 @@ When(/^(I|we)* fill in( the)* following:$/, function (pronounCase, theCase, tabl
|
|
|
360
396
|
* Fill in value for input type text by its attributeFill form fields of type
|
|
361
397
|
* input Text with the provided table according to their attributes.
|
|
362
398
|
*
|
|
363
|
-
* Example: When I fill in the following: by attr
|
|
399
|
+
* Example #1: When I fill in the following: by attr
|
|
364
400
|
* | #uname | John Smith |
|
|
365
|
-
* |
|
|
401
|
+
* | password | 1234 |
|
|
366
402
|
*
|
|
367
|
-
* Example: When I fill in the following: by its "placeholder" attribute
|
|
403
|
+
* Example #2: When I fill in the following: by its "placeholder" attribute
|
|
368
404
|
* | Your full name | John Smith |
|
|
369
405
|
* | Your Password | 1234 |
|
|
370
406
|
*/
|
|
371
|
-
When(/^(I|we)*
|
|
407
|
+
When(/^(I |we )*fill in( the)* following: by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronounCase, theCase, itsCase, attr, attrCase, table) {
|
|
372
408
|
|
|
373
409
|
var hasASpace = table.rawTable[0][0].indexOf(' ');
|
|
374
410
|
var selector = '';
|
|
@@ -414,13 +450,14 @@ When(/^(I|we)* fill in( the)* following: by( its)*( "([^"]*)?")* (attribute|attr
|
|
|
414
450
|
});
|
|
415
451
|
|
|
416
452
|
/**
|
|
417
|
-
* Selecting the option in the dropdown list field by its text label
|
|
418
|
-
*
|
|
419
|
-
* Example: When I select "
|
|
420
|
-
* Example: When I select "
|
|
453
|
+
* Selecting the option in the dropdown list field by its text label.
|
|
454
|
+
*
|
|
455
|
+
* Example #1: When I select "Mercedes" from "Cars"
|
|
456
|
+
* Example #2: When I select "saab" from "#cars"
|
|
457
|
+
* Example #3: When I select "Mercedes" from "cars"
|
|
421
458
|
*
|
|
422
459
|
*/
|
|
423
|
-
When(/^(I|we)*
|
|
460
|
+
When(/^(I |we )*select "([^"]*)?" from "([^"]*)?"$/, function (pronounCase, option, selectList) {
|
|
424
461
|
|
|
425
462
|
const hasASpace = selectList.indexOf(' ');
|
|
426
463
|
|
|
@@ -451,64 +488,90 @@ When(/^(I|we)* select "([^"]*)?" from "([^"]*)?"$/, function (pronounCase, optio
|
|
|
451
488
|
/**
|
|
452
489
|
* Checks checkbox specified.
|
|
453
490
|
*
|
|
454
|
-
* Example: When I check "Remember me"
|
|
491
|
+
* Example #1: When I check "Remember me"
|
|
492
|
+
* Example #2: When we check "Put site into maintenance mode"
|
|
455
493
|
*
|
|
456
494
|
*/
|
|
457
|
-
When(/^(I|we)*
|
|
495
|
+
When(/^(I |we )*check "([^"]*)?"$/, function (pronounCase, item) {
|
|
458
496
|
browser.checkItem(item);
|
|
459
497
|
});
|
|
460
498
|
|
|
461
499
|
/**
|
|
462
500
|
* Unchecks checkbox specified.
|
|
463
501
|
*
|
|
464
|
-
* Example: When I uncheck "Remember me"
|
|
502
|
+
* Example #1: When I uncheck "Remember me"
|
|
503
|
+
* Example #2: When we uncheck "Put site into maintenance mode"
|
|
465
504
|
*
|
|
466
505
|
*/
|
|
467
|
-
When(/^(I|we)*
|
|
506
|
+
When(/^(I |we )*uncheck "([^"]*)?"$/, function (pronounCase, item) {
|
|
468
507
|
browser.uncheckItem(item);
|
|
469
508
|
});
|
|
470
509
|
|
|
471
510
|
/**
|
|
472
511
|
* Verify, that current page is the homepage.
|
|
473
512
|
*
|
|
474
|
-
* Example: Then I should be on homepage
|
|
475
|
-
* Example:
|
|
513
|
+
* Example #1: Then I should be on homepage
|
|
514
|
+
* Example #2: And I should be on the homepage
|
|
515
|
+
* Example #3: Then I should be on frontpage
|
|
516
|
+
* Example #4: And should be on the homepage
|
|
517
|
+
* Example #5: Then should be on homepage
|
|
518
|
+
* Example #6: And we should be on homepage
|
|
519
|
+
* Example #7: Then should be on frontpage
|
|
520
|
+
* Example #8: And we should be on the homepage
|
|
476
521
|
*
|
|
477
522
|
*/
|
|
478
|
-
Then(/^(I|we)*
|
|
523
|
+
Then(/^(I |we )*should be on( the)* (homepage|frontpage)$/, function (pronounCase, theCase, pageCase) {
|
|
479
524
|
return browser.assert.urlMatches(browser.launch_url);
|
|
480
525
|
});
|
|
481
526
|
|
|
482
527
|
/**
|
|
483
528
|
* Verify, that current page is the homepage.
|
|
484
529
|
*
|
|
485
|
-
* Example: Then I should not be on homepage
|
|
530
|
+
* Example #1: Then I should not be on homepage
|
|
531
|
+
* Example #2: And I should not be on the homepage
|
|
532
|
+
* Example #3: Then I should not be on frontpage
|
|
533
|
+
* Example #4: Then we should not be on homepage
|
|
534
|
+
* Example #5: Then should not be on the homepage
|
|
535
|
+
* Example #6: And we should not be on frontpage
|
|
536
|
+
* Example #7: And we should not be on the homepage
|
|
486
537
|
*
|
|
487
538
|
*/
|
|
488
|
-
Then(/^(I|we)*
|
|
539
|
+
Then(/^(I |we )*should not be on( the)* (homepage|frontpage)$/, function (pronounCase, theCase, pageCase) {
|
|
489
540
|
return browser.assert.not.urlMatches(browser.launch_url);
|
|
490
541
|
});
|
|
491
542
|
|
|
492
543
|
/**
|
|
493
|
-
* Verify, that current page is
|
|
544
|
+
* Verify, that current page path is equal to specified path.
|
|
494
545
|
*
|
|
495
|
-
* Example: Then I should
|
|
546
|
+
* Example #1: Then I should be on "/"
|
|
547
|
+
* Example #2: And I should be on "/user/login"
|
|
548
|
+
* Example #3: And I should be on "https://un.org"
|
|
549
|
+
* Example #4: Then we should be on the "/" page
|
|
550
|
+
* Example #5: And we should be on "/user/login"
|
|
551
|
+
* Example #6: And we should be on "https://google.com"
|
|
552
|
+
* Example #7: Then should be on the "/user/reset" page
|
|
553
|
+
* Example #8: And we should be on "https://x.com"
|
|
496
554
|
*
|
|
497
555
|
*/
|
|
498
|
-
Then(/^(I|we)*
|
|
499
|
-
return browser.assert.
|
|
556
|
+
Then(/^(I |we )*should be on( the)* "([^"]*)?"( page)*$/, function (pronounCase, theCase, url, pageCase) {
|
|
557
|
+
return browser.assert.urlContains(url);
|
|
500
558
|
});
|
|
501
559
|
|
|
502
560
|
/**
|
|
503
|
-
* Verify, that current page path
|
|
561
|
+
* Verify, that current page path dose not equal to specified path.
|
|
504
562
|
*
|
|
505
|
-
* Example: Then I should be on "/"
|
|
506
|
-
* Example:
|
|
507
|
-
* Example:
|
|
563
|
+
* Example #1: Then I should not be on "/"
|
|
564
|
+
* Example #2: And I should not be on "/user/login"
|
|
565
|
+
* Example #3: And I should not be on "https://un.org"
|
|
566
|
+
* Example #4: Then we should not be on the "/" page
|
|
567
|
+
* Example #5: And we should not be on "/user/login"
|
|
568
|
+
* Example #6: Then we should not be on "https://google.com"
|
|
569
|
+
* Example #7: And should not be on "/user/reset"
|
|
570
|
+
* Example #8: And we should not be on the "https://x.com" page
|
|
508
571
|
*
|
|
509
572
|
*/
|
|
510
|
-
Then(/^(I|we)*
|
|
511
|
-
return browser.assert.urlContains(url);
|
|
573
|
+
Then(/^(I |we )*should not be on( the)* "([^"]*)?"( page)*$/, function (pronounCase, theCase, url, pageCase) {
|
|
574
|
+
return browser.assert.not.urlContains(url);
|
|
512
575
|
});
|
|
513
576
|
|
|
514
577
|
/**
|
|
@@ -525,9 +588,9 @@ Then(/^(the )*"([^"]*)?" link should contain "([^"]*)?"$/, function (theCase, el
|
|
|
525
588
|
/**
|
|
526
589
|
* Verify, that the current link contains the specified URL, found by its attributes.
|
|
527
590
|
*
|
|
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
|
|
591
|
+
* Example #1: Then the "#about-us-id" link should contain "about" by attr
|
|
592
|
+
* Example #2: And the "aboutUs" link should contain "about" by its "class" attribute
|
|
593
|
+
* Example #3: And the ".contactUs" link should contain "/contact-" by attr
|
|
531
594
|
*
|
|
532
595
|
*/
|
|
533
596
|
Then(/^(the )*"([^"]*)?" link should contain "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (theCase, attrValue, url, itsCase, attr, attrCase) {
|
|
@@ -554,7 +617,7 @@ Then(/^(the )*"([^"]*)?" link should contain "([^"]*)?" by( its)*( "([^"]*)?")*
|
|
|
554
617
|
/**
|
|
555
618
|
* Checks, that HTML response contains specific text.
|
|
556
619
|
*
|
|
557
|
-
* Example: Then the response should contain "Welcome visitor, How can I help you?"
|
|
620
|
+
* Example #1: Then the response should contain "Welcome visitor, How can I help you?"
|
|
558
621
|
*
|
|
559
622
|
*/
|
|
560
623
|
Then(/^(the )*response should contain "([^"]*)?"$/, function (theCase, expectedText) {
|
|
@@ -564,9 +627,9 @@ Then(/^(the )*response should contain "([^"]*)?"$/, function (theCase, expectedT
|
|
|
564
627
|
});
|
|
565
628
|
|
|
566
629
|
/**
|
|
567
|
-
* Checks, that HTML response contains specific text.
|
|
630
|
+
* Checks, that HTML response dose not contains specific text.
|
|
568
631
|
*
|
|
569
|
-
* Example: Then the response should not contain "
|
|
632
|
+
* Example #1: Then the response should not contain "Welcome visitor, How can I help you?"
|
|
570
633
|
*
|
|
571
634
|
*/
|
|
572
635
|
Then(/^(the )*response should not contain "([^"]*)?"$/, function (theCase, expectedText) {
|
|
@@ -575,14 +638,14 @@ Then(/^(the )*response should not contain "([^"]*)?"$/, function (theCase, expec
|
|
|
575
638
|
};
|
|
576
639
|
});
|
|
577
640
|
|
|
578
|
-
|
|
579
641
|
/**
|
|
580
642
|
* Assert, that input text contains a specific value by its label.
|
|
581
643
|
*
|
|
582
|
-
* Example: Then I should see "John Smith" in the "Username" element
|
|
644
|
+
* Example #1: Then I should see "John Smith" in the "Username" element
|
|
645
|
+
* Example #2: Then I should not see "Joe Smith" in the "Username" element
|
|
583
646
|
*
|
|
584
647
|
*/
|
|
585
|
-
Then(/^(I|we)*
|
|
648
|
+
Then(/^(I |we )*should see "([^"]*)?" in( the)* "([^"]*)?" element$/, function (pronounCase, expectedText, theCase , element) {
|
|
586
649
|
const elementField = browser.element.findByText(element, { exact: true });
|
|
587
650
|
browser.getAttribute(elementField, 'for', function (eleAttribute) {
|
|
588
651
|
return this.shouldSee = function (browser) {
|
|
@@ -598,7 +661,7 @@ Then(/^(I|we)* should see "([^"]*)?" in( the)* "([^"]*)?" element$/, function (p
|
|
|
598
661
|
* Example: Then I should see "1234" in the "pwordcss" element by attr
|
|
599
662
|
*
|
|
600
663
|
*/
|
|
601
|
-
Then(/^(I|we)*
|
|
664
|
+
Then(/^(I |we )*should see "([^"]*)?" in( the)* "([^"]*)?" element by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronounCase, expectedText, theCase, attrValue, itsCase, attr, attrCase) {
|
|
602
665
|
|
|
603
666
|
const hasASpace = attrValue.indexOf(' ');
|
|
604
667
|
|
|
@@ -624,7 +687,7 @@ Then(/^(I|we)* should see "([^"]*)?" in( the)* "([^"]*)?" element by( its)*( "([
|
|
|
624
687
|
* Example: Then I should not see "Joe Smith" in the "Username" element
|
|
625
688
|
*
|
|
626
689
|
*/
|
|
627
|
-
Then(/^(I|we)*
|
|
690
|
+
Then(/^(I |we )*should not see "([^"]*)?" in( the)* "([^"]*)?" element$/, function (pronounCase, expectedText, theCase, element) {
|
|
628
691
|
|
|
629
692
|
const elementField = browser.element.findByText(element, { exact: true });
|
|
630
693
|
browser.getAttribute(elementField, 'for', function (eleAttribute) {
|
|
@@ -641,7 +704,7 @@ Then(/^(I|we)* should not see "([^"]*)?" in( the)* "([^"]*)?" element$/, functio
|
|
|
641
704
|
* Example: Then I should not see "1234" in the "pwordcss" element by attr
|
|
642
705
|
*
|
|
643
706
|
*/
|
|
644
|
-
Then(/^(I|we)*
|
|
707
|
+
Then(/^(I |we )*should not see "([^"]*)?" in( the)* "([^"]*)?" element by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronounCase, expectedText, theCase, attrValue, itsCase, attr, attrCase) {
|
|
645
708
|
|
|
646
709
|
const hasASpace = attrValue.indexOf(' ');
|
|
647
710
|
|
|
@@ -667,7 +730,7 @@ Then(/^(I|we)* should not see "([^"]*)?" in( the)* "([^"]*)?" element by( its)*(
|
|
|
667
730
|
* Example: Then I should see a "Username" element
|
|
668
731
|
*
|
|
669
732
|
*/
|
|
670
|
-
Then(/^(I|we)*
|
|
733
|
+
Then(/^(I |we )*should see (a|an) "([^"]*)?" element$/, function (pronounCase, aAnCase, element) {
|
|
671
734
|
const elementField = browser.element.findByText(element, { exact: true });
|
|
672
735
|
browser.getAttribute(elementField, 'for', function (eleAttribute) {
|
|
673
736
|
return browser.verify.visible('#' + eleAttribute.value);
|
|
@@ -681,7 +744,7 @@ Then(/^(I|we)* should see (a|an) "([^"]*)?" element$/, function (pronounCase, aA
|
|
|
681
744
|
* Example: Then I should see a "pwordcss" element by attr
|
|
682
745
|
*
|
|
683
746
|
*/
|
|
684
|
-
Then(/^(I|we)*
|
|
747
|
+
Then(/^(I |we )*should see (a|an) "([^"]*)?" element by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronounCase, aAnCase, attrValue, itsCase, attr, attrCase) {
|
|
685
748
|
|
|
686
749
|
const hasASpace = attrValue.indexOf(' ');
|
|
687
750
|
|
|
@@ -705,7 +768,7 @@ Then(/^(I|we)* should see (a|an) "([^"]*)?" element by( its)*( "([^"]*)?")* (att
|
|
|
705
768
|
* Example: Then I should not see a "Username" element
|
|
706
769
|
*
|
|
707
770
|
*/
|
|
708
|
-
Then(/^(I|we)*
|
|
771
|
+
Then(/^(I |we )*should not see (a|an) "([^"]*)?" element$/, function (pronounCase, aAnCase, element) {
|
|
709
772
|
browser.assert.not.textContains("html", element);
|
|
710
773
|
});
|
|
711
774
|
|
|
@@ -716,7 +779,7 @@ Then(/^(I|we)* should not see (a|an) "([^"]*)?" element$/, function (pronounCase
|
|
|
716
779
|
* Example: And I should not see a "countryCss" element by attr
|
|
717
780
|
*
|
|
718
781
|
*/
|
|
719
|
-
Then(/^(I|we)*
|
|
782
|
+
Then(/^(I |we )*should not see (a|an) "([^"]*)?" element by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronounCase, aAnCase, attrValue, itsCase, attr, attrCase) {
|
|
720
783
|
|
|
721
784
|
const hasASpace = attrValue.indexOf(' ');
|
|
722
785
|
|
|
@@ -756,9 +819,9 @@ Then(/^(the )*"([^"]*)?" element should contain "([^"]*)?"$/, function (theCase
|
|
|
756
819
|
/**
|
|
757
820
|
* Assert, that element contains a specific CSS style.
|
|
758
821
|
*
|
|
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;"
|
|
822
|
+
* Example #1: Then the "body" element should not contain "color:white;"
|
|
823
|
+
* Example #2: Then the "#uname" element should not contain "border:solid 5px red;"
|
|
824
|
+
* Example #3: Then the "pword" element should not contain "font-size: 26px;"
|
|
762
825
|
*/
|
|
763
826
|
Then(/^(the )*"([^"]*)?" element should not contain "([^"]*)?"$/, function (theCase, selector, elementCss) {
|
|
764
827
|
|
|
@@ -776,14 +839,25 @@ Then(/^(the )*"([^"]*)?" element should not contain "([^"]*)?"$/, function (theC
|
|
|
776
839
|
/**
|
|
777
840
|
* Attaches file to field.
|
|
778
841
|
*
|
|
779
|
-
* Example: When I attach the file "profileIcon.jpg" to "#
|
|
842
|
+
* Example: When I attach the file "profileIcon.jpg" to "#profile-icon-upload"
|
|
780
843
|
*
|
|
781
844
|
*/
|
|
782
|
-
When(/^(I|we)*
|
|
783
|
-
|
|
784
|
-
|
|
845
|
+
When(/^(I |we )*attach( the)* file "([^"]*)?" to "([^"]*)?"$/, function (pronounCase, theCase, fileName, element) {
|
|
846
|
+
// Construct local file path.
|
|
847
|
+
let assetsFolder;
|
|
848
|
+
if (browser.globals && browser.globals.assets_folder) {
|
|
849
|
+
assetsFolder = browser.globals.assets_folder;
|
|
850
|
+
} else {
|
|
851
|
+
assetsFolder = path.join(__dirname, '/tests/assets/');
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
const localFilePath = path.resolve(assetsFolder, fileName);
|
|
785
855
|
|
|
786
|
-
|
|
856
|
+
browser.pause(5000);
|
|
857
|
+
browser.uploadFile(element, localFilePath);
|
|
858
|
+
browser.pause(10000);
|
|
859
|
+
return browser.setValue(element, fileName);
|
|
860
|
+
|
|
787
861
|
});
|
|
788
862
|
|
|
789
863
|
/**
|
|
@@ -898,12 +972,18 @@ Then(/^(the )*checkbox "([^"]*)?" is not checked$/, function (theCase, checkbox)
|
|
|
898
972
|
/**
|
|
899
973
|
* Wait a specific number of seconds.
|
|
900
974
|
*
|
|
901
|
-
|
|
902
|
-
* Example: When I wait
|
|
903
|
-
* Example: When I wait
|
|
975
|
+
|
|
976
|
+
* Example #1: When I wait 1 second
|
|
977
|
+
* Example #2: When I wait 5 seconds
|
|
978
|
+
* Example #3: When we wait 3s
|
|
979
|
+
* Example #4: And wait 2s
|
|
980
|
+
* Example #5: And wait 2 seconds
|
|
981
|
+
* Example #6: When we wait 1 second
|
|
982
|
+
* Example #7: When we wait 5 seconds
|
|
983
|
+
* Example #8: When we wait 4s
|
|
904
984
|
*
|
|
905
985
|
*/
|
|
906
|
-
When(/^(I|we)*
|
|
986
|
+
When(/^(I |we )*wait (\d*)( second| seconds|s)?$/, function (pronounCase, number, withSecondWord) {
|
|
907
987
|
var waitTime = number * 1000;
|
|
908
988
|
return browser.pause(waitTime);
|
|
909
989
|
});
|
|
@@ -911,10 +991,17 @@ When(/^(I|we)* wait (\d*)( second)*(s)*$/, function (pronounCase, number, withWo
|
|
|
911
991
|
/**
|
|
912
992
|
* Wait a max number of seconds until the element present.
|
|
913
993
|
*
|
|
914
|
-
* Example: When I wait max of
|
|
994
|
+
* Example #1: When I wait max of 1 second
|
|
995
|
+
* Example #2: When I wait max of 5 seconds
|
|
996
|
+
* Example #3: When we wait max of 3s
|
|
997
|
+
* Example #4: And wait max of 2s
|
|
998
|
+
* Example #5: And wait max of 2 seconds
|
|
999
|
+
* Example #6: When we wait max of 1 second
|
|
1000
|
+
* Example #7: When we wait max of 5 seconds
|
|
1001
|
+
* Example #8: When we wait max of 4s
|
|
915
1002
|
*
|
|
916
1003
|
*/
|
|
917
|
-
When(/^(I|we)*
|
|
1004
|
+
When(/^(I |we )*wait max of (\d*)( second| seconds|s)?$/, function (pronounCase, number, withSecondWord) {
|
|
918
1005
|
var waitTime = number * 1000;
|
|
919
1006
|
return browser.waitForElementPresent('body', waitTime);
|
|
920
1007
|
});
|
|
@@ -922,11 +1009,17 @@ When(/^(I|we)* wait max of (\d*)( second)*(s)*$/, function (pronounCase, number,
|
|
|
922
1009
|
/**
|
|
923
1010
|
* Wait a specific number of minutes.
|
|
924
1011
|
*
|
|
925
|
-
* Example: When I wait 1 minute
|
|
926
|
-
* Example: When I wait
|
|
1012
|
+
* Example #1: When I wait 1 minute
|
|
1013
|
+
* Example #2: When I wait 10 minutes
|
|
1014
|
+
* Example #3: When we wait 1m
|
|
1015
|
+
* Example #4: And wait 2s
|
|
1016
|
+
* Example #5: And wait 2 minutes
|
|
1017
|
+
* Example #6: When we wait 1 minute
|
|
1018
|
+
* Example #7: When we wait 10 minutes
|
|
1019
|
+
* Example #8: When we wait 2m
|
|
927
1020
|
*
|
|
928
1021
|
*/
|
|
929
|
-
When(/^(I|we)*
|
|
1022
|
+
When(/^(I |we )*wait (\d*)( minute| minutes|m)?$/, function (pronounCase, number, withMinuteWord) {
|
|
930
1023
|
var waitTime = number * 1000 * 60;
|
|
931
1024
|
return browser.pause(waitTime);
|
|
932
1025
|
});
|
|
@@ -934,10 +1027,17 @@ When(/^(I|we)* wait (\d*)( minute)*(m)*$/, function (pronounCase, number, withWo
|
|
|
934
1027
|
/**
|
|
935
1028
|
* Wait a max number of minutes until the element present.
|
|
936
1029
|
*
|
|
937
|
-
* Example: When I wait
|
|
1030
|
+
* Example #1: When I wait 1 minute
|
|
1031
|
+
* Example #2: When I wait 10 minutes
|
|
1032
|
+
* Example #3: When we wait 1m
|
|
1033
|
+
* Example #4: And wait 2s
|
|
1034
|
+
* Example #5: And wait 2 minutes
|
|
1035
|
+
* Example #6: When we wait 1 minute
|
|
1036
|
+
* Example #7: When we wait 10 minutes
|
|
1037
|
+
* Example #8: When we wait 2m
|
|
938
1038
|
*
|
|
939
1039
|
*/
|
|
940
|
-
When(/^(I|we)*
|
|
1040
|
+
When(/^(I |we )*wait max of (\d*)( minute| minutes|m)?$/, function (pronounCase, number, withMinuteWord) {
|
|
941
1041
|
var waitTime = number * 1000 * 60;
|
|
942
1042
|
return browser.waitForElementPresent('body', waitTime);
|
|
943
1043
|
});
|
|
@@ -945,16 +1045,19 @@ When(/^(I|we)* wait max of (\d*)( minute)*(m)*$/, function (pronounCase, number,
|
|
|
945
1045
|
/**
|
|
946
1046
|
* Wait until the page is loaded.
|
|
947
1047
|
*
|
|
948
|
-
* Example: When I wait until the page is loaded
|
|
1048
|
+
* Example #1: When I wait until the page is loaded
|
|
1049
|
+
* Example #1: When we wait until the page is loaded
|
|
1050
|
+
* Example #2: When wait until page loaded
|
|
949
1051
|
*
|
|
950
1052
|
*/
|
|
951
|
-
When(/^(I|we)*
|
|
1053
|
+
When(/^(I |we )*wait until( the)* page( is)* loaded*$/, function (pronounCase, theCase, withIs) {
|
|
952
1054
|
return browser.waitForElementPresent('body', 10000);
|
|
953
1055
|
});
|
|
1056
|
+
|
|
954
1057
|
/**
|
|
955
1058
|
* Checks, that the current page response status is equal the specified code.
|
|
956
1059
|
*
|
|
957
|
-
* Example: Then the response status code should be 200
|
|
1060
|
+
* Example #1: Then the response status code should be 200
|
|
958
1061
|
*
|
|
959
1062
|
*/
|
|
960
1063
|
Then(/^(the )*response status code should be (\d+)$/, function (theCase, expectedStatusCode) {
|
|
@@ -975,7 +1078,7 @@ Then(/^(the )*response status code should be (\d+)$/, function (theCase, expecte
|
|
|
975
1078
|
/**
|
|
976
1079
|
* Checks, that the current page response status is not equal the specified code.
|
|
977
1080
|
*
|
|
978
|
-
* Example: And the response status code should not be 404
|
|
1081
|
+
* Example #1: And the response status code should not be 404
|
|
979
1082
|
*
|
|
980
1083
|
*/
|
|
981
1084
|
Then(/^(the )*response status code should not be (\d+)$/, function ( theCase, expectedStatusCode) {
|
|
@@ -999,7 +1102,7 @@ Then(/^(the )*response status code should not be (\d+)$/, function ( theCase, ex
|
|
|
999
1102
|
* Example: Then I should see text matching "^T\w+" //pattern of word start with 'T'
|
|
1000
1103
|
*
|
|
1001
1104
|
*/
|
|
1002
|
-
Then(/^(I|we)*
|
|
1105
|
+
Then(/^(I |we )*should see text matching "([^"]*)?"$/, function (pronounCase, textPattern) {
|
|
1003
1106
|
browser.elements('css selector', 'body', function (elements) {
|
|
1004
1107
|
elements.value.forEach(function (elementsObj) {
|
|
1005
1108
|
return browser.assert.textMatches(elementsObj, textPattern);
|
|
@@ -1010,10 +1113,10 @@ Then(/^(I|we)* should see text matching "([^"]*)?"$/, function (pronounCase, tex
|
|
|
1010
1113
|
/**
|
|
1011
1114
|
* Checks, that page not contains text matching specified pattern.
|
|
1012
1115
|
*
|
|
1013
|
-
* Example: Then I should not see text matching "^O\w+" //pattern of word start with 'O'
|
|
1116
|
+
* Example #1: Then I should not see text matching "^O\w+" //pattern of word start with 'O'
|
|
1014
1117
|
*
|
|
1015
1118
|
*/
|
|
1016
|
-
Then(/^(I|we)*
|
|
1119
|
+
Then(/^(I |we )*should not see text matching "([^"]*)?"$/, function (pronounCase, textPattern) {
|
|
1017
1120
|
browser.elements('css selector', 'body', function (elements) {
|
|
1018
1121
|
elements.value.forEach(function (elementsObj) {
|
|
1019
1122
|
return browser.assert.not.textMatches(elementsObj, textPattern);
|
|
@@ -1024,27 +1127,25 @@ Then(/^(I|we)* should not see text matching "([^"]*)?"$/, function (pronounCase,
|
|
|
1024
1127
|
/**
|
|
1025
1128
|
* Checks, that page contains text matching specified pattern.
|
|
1026
1129
|
*
|
|
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
|
-
*
|
|
1130
|
+
* 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
|
|
1131
|
+
* // pattern of DD/MM/YYYY or DD-MM-YYYY
|
|
1029
1132
|
*
|
|
1030
1133
|
*/
|
|
1031
|
-
Then(/^(I|we)*
|
|
1134
|
+
Then(/^(I |we )*should see text matching "([^"]*)?" in( the)* "([^"]*)?" element$/, function (pronounCase, textPattern, theCase, element) {
|
|
1032
1135
|
return this.shouldSeePattern = function (browser) {
|
|
1033
1136
|
browser.assert.textMatches(element, textPattern);
|
|
1034
1137
|
};
|
|
1035
1138
|
});
|
|
1036
1139
|
|
|
1037
1140
|
/**
|
|
1038
|
-
* Checks, that page
|
|
1141
|
+
* Checks, that page dose not contain text matching specified pattern.
|
|
1039
1142
|
*
|
|
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
|
-
*
|
|
1143
|
+
* 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
|
|
1144
|
+
* // pattern of DD/MM/YYYY or DD-MM-YYYY
|
|
1042
1145
|
*
|
|
1043
1146
|
*/
|
|
1044
|
-
Then(/^(I|we)*
|
|
1045
|
-
return
|
|
1046
|
-
browser.assert.not.textMatches(element, textPattern);
|
|
1047
|
-
};
|
|
1147
|
+
Then(/^(I |we )*should not see text matching "([^"]*)?" in( the)* "([^"]*)?" element$/, function (pronounCase, textPattern, theCase, element) {
|
|
1148
|
+
return browser.assert.not.textMatches(element, textPattern);
|
|
1048
1149
|
});
|
|
1049
1150
|
|
|
1050
1151
|
/**
|
|
@@ -1075,7 +1176,7 @@ Then(/^(the )*url should not match "([^"]*)?"$/, function (theCase, pattern) {
|
|
|
1075
1176
|
* Example #3: And we scroll down 500
|
|
1076
1177
|
* Example #4: When scrolling down 1200
|
|
1077
1178
|
*/
|
|
1078
|
-
When(/^(I|we
|
|
1179
|
+
When(/^(I scroll|we scroll|scrolling)? down( ([^"]*)?)*$/, function(pronounCase, value) {
|
|
1079
1180
|
// Default scroll value
|
|
1080
1181
|
let scrollValue = 350;
|
|
1081
1182
|
|
|
@@ -1108,7 +1209,7 @@ When(/^(I|we)? (scroll|scrolling) down( ([^"]*)?)*$/, function(pronounCase, scro
|
|
|
1108
1209
|
* Example #4: When scrolling up 750
|
|
1109
1210
|
*
|
|
1110
1211
|
*/
|
|
1111
|
-
When(/^(I|we
|
|
1212
|
+
When(/^(I scroll|we scroll|scrolling)? up( ([^"]*)?)*$/, function(pronounCase, value) {
|
|
1112
1213
|
// Parse and validate the scroll value
|
|
1113
1214
|
let scrollValue = 350; // default value
|
|
1114
1215
|
|
|
@@ -1140,7 +1241,7 @@ When(/^(I|we)? (scroll|scrolling) up( ([^"]*)?)*$/, function(pronounCase, scroll
|
|
|
1140
1241
|
* Example #2: And we scrolling to the top
|
|
1141
1242
|
* Example #3: When scrolling to the top of the page
|
|
1142
1243
|
*/
|
|
1143
|
-
When(/^(I|we
|
|
1244
|
+
When(/^(I scroll|we scroll|scrolling)? to( the)* top( of the page)*$/, function(pronounCase, theCase, pageCase) {
|
|
1144
1245
|
return browser.executeScript('document.documentElement.scrollTop = 0;');
|
|
1145
1246
|
});
|
|
1146
1247
|
|
|
@@ -1151,7 +1252,7 @@ When(/^(I|we)* (scroll|scrolling) to( the)* top( of the page)*$/, function(prono
|
|
|
1151
1252
|
* Example #2: And we scroll to bottom
|
|
1152
1253
|
* Example #3: When scrolling to the bottom of the page
|
|
1153
1254
|
*/
|
|
1154
|
-
When(/^(I|we
|
|
1255
|
+
When(/^(I scroll|we scroll|scrolling)? to( the)* bottom( of the page)*$/, function(pronounCase, theCase, pageCase) {
|
|
1155
1256
|
return browser.executeScript('window.scrollTo(0, document.body.scrollHeight);');
|
|
1156
1257
|
});
|
|
1157
1258
|
|
|
@@ -1162,7 +1263,7 @@ When(/^(I|we)* (scroll|scrolling) to( the)* bottom( of the page)*$/, function(pr
|
|
|
1162
1263
|
* Example #2: And we scroll to top of "#sidebar"
|
|
1163
1264
|
* Example #3: When scrolling to top of "#main-container"
|
|
1164
1265
|
*/
|
|
1165
|
-
When(/^(I|we
|
|
1266
|
+
When(/^(I scroll|we scroll|scrolling)? to top of "([^"]*)"$/, function(pronounCase, selector) {
|
|
1166
1267
|
// Validate selector
|
|
1167
1268
|
if (!selector || selector.trim() === '') {
|
|
1168
1269
|
throw new Error('Selector cannot be empty. Please provide a valid CSS selector.');
|
|
@@ -1203,7 +1304,7 @@ When(/^(I|we)* (scroll|scrolling) to top of "([^"]*)"$/, function(pronounCase, s
|
|
|
1203
1304
|
* Example #2: And we scrolling to bottom of "#sidebar"
|
|
1204
1305
|
* Example #3: When scrolling to bottom of "#main-container"
|
|
1205
1306
|
*/
|
|
1206
|
-
When(/^(I|we
|
|
1307
|
+
When(/^(I scroll|we scroll|scrolling)? to bottom of "([^"]*)"$/, function(pronounCase, selector) {
|
|
1207
1308
|
// Validate selector
|
|
1208
1309
|
if (!selector || selector.trim() === '') {
|
|
1209
1310
|
throw new Error('Selector cannot be empty. Please provide a valid CSS selector.');
|
|
@@ -1235,4 +1336,4 @@ When(/^(I|we)* (scroll|scrolling) to bottom of "([^"]*)"$/, function(pronounCase
|
|
|
1235
1336
|
} catch (error) {
|
|
1236
1337
|
throw new Error(`Failed to scroll to bottom of element "${selector}": ${error.message}`);
|
|
1237
1338
|
}
|
|
1238
|
-
});
|
|
1339
|
+
});
|