webship-js 1.0.30 → 1.0.32
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 +42 -18
- package/.gitlab-ci.yml +43 -32
- package/assets/config_templates/circleci-linux-chrome.conf.js +1 -1
- package/assets/config_templates/github-linux-chrome.conf.js +1 -1
- package/examples/test--then--i-should--not--see-text-in-element.html +2 -2
- package/examples/test--then--i-should--see-text-in-element.html +2 -2
- package/examples/test--then--the-element-should_not-contain-cssproperty.html +2 -2
- package/examples/test--when--i-fill-in.html +4 -4
- package/examples/test--when--i-press-button.html +5 -2
- package/examples/test--when--i-select-option-from-dropdownlist.html +1 -1
- package/nightwatch.conf.js +2 -2
- package/package.json +1 -1
- package/tests/features/test--then--i-should--not--see-text-in-element.feature +9 -14
- package/tests/features/test--then--i-should--see-text-in-element-by-attr.feature +10 -0
- package/tests/features/test--then--i-should--see-text-in-element.feature +10 -0
- package/tests/features/test--then--i-should-not-see-an-element-by-attr.feature +8 -0
- package/tests/features/test--then--i-should-not-see-an-element.feature +8 -0
- package/tests/features/test--then--i-should-see-an-element-by-attr.feature +8 -0
- package/tests/features/test--then--i-should-see-an-element.feature +6 -6
- package/tests/features/test--then--the-checkbox-is-checked.feature +2 -2
- package/tests/features/test--then--the-checkbox-should-be-checked.feature +2 -2
- package/tests/features/{test--then--the-element-should_not-contain-cssproperty.feature → test--then--the-element-should-contain-cssproperty.feature} +4 -10
- package/tests/features/test--then--the-element-should-not-contain-cssproperty.feature +10 -0
- package/tests/features/test--then--the-field-should-contain-value.feature +3 -3
- package/tests/features/test--when--i-attach-file-to-feild.feature +1 -1
- package/tests/features/test--when--i-check-checkbox.feature +4 -4
- package/tests/features/test--when--i-click-link-by-attribute.feature +22 -0
- package/tests/features/test--when--i-fill-in-by-attr.feature +31 -0
- package/tests/features/test--when--i-fill-in-table-by-attr.feature +19 -0
- package/tests/features/test--when--i-fill-in.feature +13 -12
- package/tests/features/test--when--i-press-button-by-attribute.feature +15 -0
- package/tests/features/test--when--i-press-button.feature +2 -2
- package/tests/features/test--when--i-reload-page.feature +1 -1
- package/tests/features/test--when--i-select-option-from-dropdownlist-by-attr.feature +16 -0
- package/tests/features/test--when--i-select-option-from-dropdownlist.feature +6 -8
- package/tests/step-definitions/webship.js +418 -55
|
@@ -107,7 +107,34 @@ When(/^(I|we)* move backward one page$/, function (pronoundCase) {
|
|
|
107
107
|
*
|
|
108
108
|
*/
|
|
109
109
|
When(/^(I|we)* press "([^"]*)?"$/, function (pronoundCase, element) {
|
|
110
|
-
browser.click(
|
|
110
|
+
browser.click("[value='" + element +"']");
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Presses button with specified element
|
|
115
|
+
* Example: When I press "btn-pressid" by attr
|
|
116
|
+
* Example: When I press "btn-pressid" by attribute
|
|
117
|
+
* Example: And I press "Your full name" by "placeholder" attribute
|
|
118
|
+
* Example: And I press "Your full name" by its "placeholder" attribute
|
|
119
|
+
* Example: And I press "save-name" by "data-drupal-selector" attr
|
|
120
|
+
*
|
|
121
|
+
*/
|
|
122
|
+
When(/^(I|we)* press "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, attrValue, itsCase, attr, attrCase) {
|
|
123
|
+
|
|
124
|
+
const hasASpace = attrValue.indexOf(' ');
|
|
125
|
+
|
|
126
|
+
var selector = '';
|
|
127
|
+
if (!attr && hasASpace == -1){
|
|
128
|
+
selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "]," + '[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
129
|
+
}
|
|
130
|
+
else if (!attr && hasASpace > -1){
|
|
131
|
+
selector ='[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
selector = '[' + attr + '="' + attrValue + '"]';
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
browser.click(selector);
|
|
111
138
|
});
|
|
112
139
|
|
|
113
140
|
/**
|
|
@@ -120,12 +147,43 @@ When(/^(I|we)* click "([^"]*)?"$/, function (pronoundCase, item) {
|
|
|
120
147
|
return browser.click("link text", item);
|
|
121
148
|
});
|
|
122
149
|
|
|
150
|
+
/**
|
|
151
|
+
* Click Link with specified element
|
|
152
|
+
* Example: When I click "#aboutUsid" by attr
|
|
153
|
+
* Example: When I click "aboutUsCss" by attribute
|
|
154
|
+
* Example: And I click "aboutUsCss" by "class" attr
|
|
155
|
+
* Example: And I click "aboutUsid" by its "id" attribute
|
|
156
|
+
*
|
|
157
|
+
*/
|
|
158
|
+
When(/^(I|we)* click "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, attrValue, itsCase, attr, attrCase) {
|
|
159
|
+
|
|
160
|
+
const hasASpace = attrValue.indexOf(' ');
|
|
161
|
+
var selector = '';
|
|
162
|
+
|
|
163
|
+
if((attrValue.startsWith('#') || attrValue.startsWith('.')) && hasASpace == -1){
|
|
164
|
+
selector = attrValue;
|
|
165
|
+
}
|
|
166
|
+
else if (!attr && hasASpace == -1){
|
|
167
|
+
selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "]," + '[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
168
|
+
}
|
|
169
|
+
else if (!attr && hasASpace > -1){
|
|
170
|
+
selector ='[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
selector = '[' + attr + '="' + attrValue + '"]';
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return browser.click(selector);
|
|
177
|
+
|
|
178
|
+
});
|
|
179
|
+
|
|
123
180
|
/**
|
|
124
181
|
* Reloads current page
|
|
125
182
|
* Example: When I reload page
|
|
126
183
|
* Example: And I reload page
|
|
127
184
|
*
|
|
128
185
|
*/
|
|
186
|
+
|
|
129
187
|
When(/^(I|we)* reload page$/, function (pronoundCase) {
|
|
130
188
|
return browser.refresh(browser.getCurrentUrl());
|
|
131
189
|
});
|
|
@@ -147,54 +205,249 @@ When(/^(I|we)* reload the page$/, function (pronoundCase) {
|
|
|
147
205
|
*
|
|
148
206
|
*/
|
|
149
207
|
When(/^(I|we)* fill in "([^"]*)?" with "([^"]*)?"$/, function (pronoundCase, field, value) {
|
|
150
|
-
browser.
|
|
208
|
+
const elementField = browser.element.findByText(field);
|
|
209
|
+
browser.getAttribute(elementField, 'for', function (eleAttribute) {
|
|
210
|
+
return browser.setValue('#' + eleAttribute.value, value);
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Fill input type text with value by its attribute
|
|
216
|
+
* Example: When I fill in "#uname" by attr
|
|
217
|
+
* Example: When I fill in "uname" with "John Smith" by attr
|
|
218
|
+
* Example: And I fill in "pwordcss" with "1234" by "class" attr
|
|
219
|
+
* Example: And I fill in "Your full name" with "John Smith" by its "placeholder" attribute
|
|
220
|
+
*
|
|
221
|
+
*/
|
|
222
|
+
When(/^(I|we)* fill in "([^"]*)?" with "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, attrValue, txtValue, itsCase, attr, attrCase) {
|
|
223
|
+
|
|
224
|
+
const hasASpace = attrValue.indexOf(' ');
|
|
225
|
+
var selector = '';
|
|
226
|
+
|
|
227
|
+
if((attrValue.startsWith('#') || attrValue.startsWith('.')) && hasASpace == -1){
|
|
228
|
+
selector = attrValue;
|
|
229
|
+
}
|
|
230
|
+
else if (!attr && hasASpace == -1){
|
|
231
|
+
selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "]," + '[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
232
|
+
}
|
|
233
|
+
else if (!attr && hasASpace > -1){
|
|
234
|
+
selector ='[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
selector = '[' + attr + '="' + attrValue + '"]';
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return browser.setValue(selector, txtValue);
|
|
241
|
+
|
|
151
242
|
});
|
|
152
243
|
|
|
153
244
|
/**
|
|
154
|
-
*
|
|
155
|
-
* Example: When I fill in "
|
|
245
|
+
* Fill input type text with empty value by its Label
|
|
246
|
+
* Example: When I fill in "Username" with:
|
|
156
247
|
*
|
|
157
248
|
*/
|
|
158
249
|
When(/^(I|we)* fill in "([^"]*)?" with:$/, function (pronoundCase, field) {
|
|
159
|
-
browser.
|
|
250
|
+
const elementField = browser.element.findByText(field);
|
|
251
|
+
browser.getAttribute(elementField, 'for', function (eleAttribute) {
|
|
252
|
+
return browser.setValue('#' + eleAttribute.value, '');
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Fill input type text with empty value by its attribute
|
|
258
|
+
* Example: When I fill in "#uname" with: by attr
|
|
259
|
+
* Example: When I fill in "uname" with: by attr
|
|
260
|
+
* Example: And I fill in "pwordcss" with: by "class" attr
|
|
261
|
+
* Example: And I fill in "Your full name" with: by its "placeholder" attribute
|
|
262
|
+
*
|
|
263
|
+
*/
|
|
264
|
+
When(/^(I|we)* fill in "([^"]*)?" with: by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, attrValue , itsCase, attr, attrCase) {
|
|
265
|
+
|
|
266
|
+
const hasASpace = attrValue.indexOf(' ');
|
|
267
|
+
var selector = '';
|
|
268
|
+
|
|
269
|
+
if((attrValue.startsWith('#') || attrValue.startsWith('.')) && hasASpace == -1){
|
|
270
|
+
selector = attrValue;
|
|
271
|
+
}
|
|
272
|
+
else if (!attr && hasASpace == -1){
|
|
273
|
+
selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "]," + '[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
274
|
+
}
|
|
275
|
+
else if (!attr && hasASpace > -1){
|
|
276
|
+
selector ='[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
selector = '[' + attr + '="' + attrValue + '"]';
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return browser.setValue(selector, '');
|
|
160
283
|
});
|
|
161
284
|
|
|
162
285
|
/**
|
|
163
|
-
*
|
|
164
|
-
* Example:
|
|
286
|
+
* Fill in value for input type text by its Label
|
|
287
|
+
* Example: When I fill in "webshipco" for "Username"
|
|
165
288
|
*
|
|
166
289
|
*/
|
|
167
290
|
When(/^(I|we)* fill in "([^"]*)?" for "([^"]*)?"$/, function (pronoundCase, value, field) {
|
|
168
|
-
browser.
|
|
291
|
+
const elementField = browser.element.findByText(field);
|
|
292
|
+
browser.getAttribute(elementField, 'for', function (eleAttribute) {
|
|
293
|
+
return browser.setValue('#' + eleAttribute.value, value);
|
|
294
|
+
});
|
|
169
295
|
});
|
|
170
296
|
|
|
171
297
|
/**
|
|
172
|
-
*
|
|
173
|
-
* Example: When I fill in
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
* Example: And I fill in
|
|
177
|
-
* | username | webshipco |
|
|
178
|
-
* | password | 1234 |
|
|
298
|
+
* Fill in value for input type text by its attribute
|
|
299
|
+
* Example: When I fill in "John Smith" for "#uname" by attr
|
|
300
|
+
* Example: When I fill in "John Smith" for "uname" by attr
|
|
301
|
+
* Example: And I fill in "1234" for "pwordcss" by "class" attr
|
|
302
|
+
* Example: And I fill in "John Smith" for "Your full name" by its "placeholder" attribute
|
|
179
303
|
*
|
|
180
304
|
*/
|
|
305
|
+
When(/^(I|we)* fill in "([^"]*)?" for "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, txtValue, attrValue, itsCase, attr, attrCase) {
|
|
306
|
+
|
|
307
|
+
const hasASpace = attrValue.indexOf(' ');
|
|
308
|
+
var selector = '';
|
|
309
|
+
|
|
310
|
+
if((attrValue.startsWith('#') || attrValue.startsWith('.')) && hasASpace == -1){
|
|
311
|
+
selector = attrValue;
|
|
312
|
+
}
|
|
313
|
+
else if (!attr && hasASpace == -1){
|
|
314
|
+
selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "]," + '[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
315
|
+
}
|
|
316
|
+
else if (!attr && hasASpace > -1){
|
|
317
|
+
selector ='[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
selector = '[' + attr + '="' + attrValue + '"]';
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
return browser.setValue(selector, txtValue);
|
|
324
|
+
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Fills in form input fields type text with provided table by there labels
|
|
329
|
+
* Example: When I fill in the following:
|
|
330
|
+
* | Username | webshipco |
|
|
331
|
+
* | Password | 1234 |
|
|
332
|
+
*/
|
|
333
|
+
|
|
181
334
|
When(/^(I|we)* fill in the following:$/, function (pronoundCase, table) {
|
|
182
335
|
|
|
183
|
-
browser.
|
|
336
|
+
var elementField = browser.element.findByText(table.rawTable[0][0]);
|
|
337
|
+
browser.getAttribute(elementField, 'for', function (eleAttribute) {
|
|
338
|
+
browser.setValue('#' + eleAttribute.value, table.rawTable[0][1]);
|
|
339
|
+
});
|
|
340
|
+
|
|
184
341
|
table.rows().forEach(row => {
|
|
185
|
-
|
|
186
|
-
|
|
342
|
+
|
|
343
|
+
elementField = browser.element.findByText(row[0]);
|
|
344
|
+
browser.getAttribute(elementField, 'for', function (eleAttribute2) {
|
|
345
|
+
browser.setValue('#' + eleAttribute2.value, row[1]);
|
|
346
|
+
});
|
|
187
347
|
});
|
|
188
348
|
});
|
|
189
349
|
|
|
190
350
|
/**
|
|
191
|
-
*
|
|
351
|
+
* Fill in value for input type text by its attributeFill form fields of type input Text with the provided table according to their attributes
|
|
352
|
+
* Example: When I fill in the following: by attr
|
|
353
|
+
* | #uname | John Smith |
|
|
354
|
+
* | pwordcss | 1234 |
|
|
355
|
+
|
|
356
|
+
* Example: When I fill in the following: by its "placeholder" attribute
|
|
357
|
+
* | Your full name | John Smith |
|
|
358
|
+
* | Your Password | 1234 |
|
|
359
|
+
*/
|
|
360
|
+
|
|
361
|
+
When(/^(I|we)* fill in the following: by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, itsCase, attr, attrCase, table) {
|
|
362
|
+
|
|
363
|
+
var hasASpace = table.rawTable[0][0].indexOf(' ');
|
|
364
|
+
var selector = '';
|
|
365
|
+
|
|
366
|
+
if((table.rawTable[0][0].startsWith('#') || table.rawTable[0][0].startsWith('.')) && hasASpace == -1){
|
|
367
|
+
selector = table.rawTable[0][0];
|
|
368
|
+
}
|
|
369
|
+
else if (!attr && hasASpace == -1){
|
|
370
|
+
selector = table.rawTable[0][0] + ',#' + table.rawTable[0][0] + ',.' + table.rawTable[0][0] + ',[name=' + table.rawTable[0][0] + "]," + '[value="' + table.rawTable[0][0] + '"],[placeholder="' + table.rawTable[0][0] + '"]';
|
|
371
|
+
}
|
|
372
|
+
else if (!attr && hasASpace > -1){
|
|
373
|
+
selector ='[value="' + table.rawTable[0][0] + '"],[placeholder="' + table.rawTable[0][0] + '"]';
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
selector = '[' + attr + '="' + table.rawTable[0][0] + '"]';
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
browser.setValue(selector, table.rawTable[0][1]);
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
table.rows().forEach(row => {
|
|
383
|
+
|
|
384
|
+
hasASpace = row[0].indexOf(' ');
|
|
385
|
+
var selector = '';
|
|
386
|
+
|
|
387
|
+
if((row[0].startsWith('#') || row[0].startsWith('.')) && hasASpace == -1){
|
|
388
|
+
selector = row[0];
|
|
389
|
+
}
|
|
390
|
+
else if (!attr && hasASpace == -1){
|
|
391
|
+
|
|
392
|
+
selector = row[0] + ',#' + row[0] + ',.' + row[0] + ',[name=' + row[0] + "]," + '[value="' + row[0] + '"],[placeholder="' + row[0] + '"]';
|
|
393
|
+
}
|
|
394
|
+
else if (!attr && hasASpace > -1){
|
|
395
|
+
selector ='[value="' + row[0] + '"],[placeholder="' + row[0] + '"]';
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
selector = '[' + attr + '="' + row[0] + '"]';
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
browser.setValue(selector, row[1]);
|
|
402
|
+
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Selecting the option in the dropdown list field by its text label
|
|
192
408
|
* Example: When I select "Mercedes" from "Cars"
|
|
193
409
|
*
|
|
194
410
|
*/
|
|
195
411
|
When(/^(I|we)* select "([^"]*)?" from "([^"]*)?"$/, function (pronoundCase, option, dropdownlist) {
|
|
196
412
|
|
|
197
|
-
browser.
|
|
413
|
+
const elementField = browser.element.findByText(dropdownlist);
|
|
414
|
+
browser.getAttribute(elementField, 'for', function (eleAttribute) {
|
|
415
|
+
return browser.waitForElementVisible('css selector', '#' + eleAttribute.value)
|
|
416
|
+
.click('#' + eleAttribute.value)
|
|
417
|
+
.click(browser.element.findByText(option))
|
|
418
|
+
.click('#' + eleAttribute.value);
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Selects option in select field
|
|
424
|
+
* Example: When I select "Mercedes" from "cars" its "id" attr
|
|
425
|
+
* Example: When I select "Saab" from "#cars" by attr
|
|
426
|
+
*
|
|
427
|
+
*/
|
|
428
|
+
|
|
429
|
+
When(/^(I|we)* select "([^"]*)?" from "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, option, attrValue, itsCase, attr, attrCase) {
|
|
430
|
+
|
|
431
|
+
const hasASpace = attrValue.indexOf(' ');
|
|
432
|
+
|
|
433
|
+
var selector = '';
|
|
434
|
+
if((attrValue.startsWith('#') || attrValue.startsWith('.')) && hasASpace == -1){
|
|
435
|
+
selector = attrValue;
|
|
436
|
+
}
|
|
437
|
+
else if (!attr && hasASpace == -1){
|
|
438
|
+
selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "]," + '[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
439
|
+
}
|
|
440
|
+
else if (!attr && hasASpace > -1){
|
|
441
|
+
selector ='[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
442
|
+
}
|
|
443
|
+
else {
|
|
444
|
+
selector = '[' + attr + '="' + attrValue + '"]';
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
return browser.waitForElementVisible('css selector', selector)
|
|
448
|
+
.click(selector)
|
|
449
|
+
.click(browser.element.findByText(option))
|
|
450
|
+
.click(selector);
|
|
198
451
|
});
|
|
199
452
|
|
|
200
453
|
/**
|
|
@@ -288,71 +541,154 @@ Then(/^the response should not contain "([^"]*)?"$/, function (expectedText) {
|
|
|
288
541
|
|
|
289
542
|
|
|
290
543
|
/**
|
|
291
|
-
* Assert, that
|
|
292
|
-
* Example: Then I should see "John Smith" in the "
|
|
544
|
+
* Assert, that input text contains a specific value by its label
|
|
545
|
+
* Example: Then I should see "John Smith" in the "Username" element
|
|
293
546
|
*
|
|
294
547
|
*/
|
|
295
548
|
Then(/^(I|we)* should see "([^"]*)?" in the "([^"]*)?" element$/, function (pronoundCase, expectedText, element) {
|
|
549
|
+
const elementField = browser.element.findByText(element);
|
|
550
|
+
browser.getAttribute(elementField, 'for', function (eleAttribute) {
|
|
551
|
+
return this.shouldSee = function (browser) {
|
|
552
|
+
browser.assert.textContains('#' + eleAttribute.value, expectedText);
|
|
553
|
+
};
|
|
554
|
+
});
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Assert, that input text contains a specific value by its attributes
|
|
559
|
+
* Example: Then I should see "John Smith" in the "uname" element by its "id" attr
|
|
560
|
+
* Example: Then I should see "1234" in the "pwordcss" element by attr
|
|
561
|
+
*
|
|
562
|
+
*/
|
|
563
|
+
Then(/^(I|we)* should see "([^"]*)?" in the "([^"]*)?" element by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, expectedText, attrValue, itsCase, attr, attrCase) {
|
|
564
|
+
|
|
565
|
+
const hasASpace = attrValue.indexOf(' ');
|
|
566
|
+
|
|
567
|
+
var selector = '';
|
|
568
|
+
if (!attr && hasASpace == -1){
|
|
569
|
+
selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "]," + '[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
570
|
+
}
|
|
571
|
+
else if (!attr && hasASpace > -1){
|
|
572
|
+
selector ='[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
selector = '[' + attr + '="' + attrValue + '"]';
|
|
576
|
+
}
|
|
577
|
+
|
|
296
578
|
return this.shouldSee = function (browser) {
|
|
297
|
-
browser.assert.textContains(
|
|
579
|
+
browser.assert.textContains(selector, expectedText);
|
|
298
580
|
};
|
|
299
581
|
});
|
|
300
582
|
|
|
301
583
|
/**
|
|
302
|
-
* Assert, that
|
|
303
|
-
* Example: Then I should not see "Joe Smith" in the "
|
|
584
|
+
* Assert, that input text does not contain a specific value to be by its label
|
|
585
|
+
* Example: Then I should not see "Joe Smith" in the "Username" element
|
|
304
586
|
*
|
|
305
587
|
*/
|
|
306
588
|
Then(/^(I|we)* should not see "([^"]*)?" in the "([^"]*)?" element$/, function (pronoundCase, expectedText, element) {
|
|
307
589
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
590
|
+
const elementField = browser.element.findByText(element);
|
|
591
|
+
browser.getAttribute(elementField, 'for', function (eleAttribute) {
|
|
592
|
+
return this.shouldSee = function (browser) {
|
|
593
|
+
browser.assert.not.textContains('#' + eleAttribute.value, expectedText);
|
|
594
|
+
};
|
|
595
|
+
});
|
|
311
596
|
});
|
|
312
597
|
|
|
313
598
|
/**
|
|
314
|
-
* Assert, that
|
|
315
|
-
* Example: Then I should see
|
|
316
|
-
*
|
|
599
|
+
* Assert, that input text contains a specific value by its attributes
|
|
600
|
+
* Example: Then I should not see "John Smith" in the "uname" element by its "id" attr
|
|
601
|
+
* Example: Then I should not see "1234" in the "pwordcss" element by attr
|
|
602
|
+
*
|
|
317
603
|
*/
|
|
318
|
-
Then(/^(I|we)* should see
|
|
319
|
-
|
|
604
|
+
Then(/^(I|we)* should not see "([^"]*)?" in the "([^"]*)?" element by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, expectedText, attrValue, itsCase, attr, attrCase) {
|
|
605
|
+
|
|
606
|
+
const hasASpace = attrValue.indexOf(' ');
|
|
607
|
+
|
|
608
|
+
var selector = '';
|
|
609
|
+
if (!attr && hasASpace == -1){
|
|
610
|
+
selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "]," + '[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
611
|
+
}
|
|
612
|
+
else if (!attr && hasASpace > -1){
|
|
613
|
+
selector ='[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
614
|
+
}
|
|
615
|
+
else {
|
|
616
|
+
selector = '[' + attr + '="' + attrValue + '"]';
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
return this.shouldSee = function (browser) {
|
|
620
|
+
browser.assert.not.textContains(selector, expectedText);
|
|
621
|
+
};
|
|
320
622
|
});
|
|
321
623
|
|
|
322
624
|
/**
|
|
323
|
-
* Assert, that element exists on current page
|
|
324
|
-
* Example: Then I should see
|
|
625
|
+
* Assert, that element exists on current page by its label
|
|
626
|
+
* Example: Then I should see a "Username" element
|
|
325
627
|
*
|
|
326
628
|
*/
|
|
327
|
-
Then(/^(I|we)* should see an "([^"]*)?" element$/, function (pronoundCase, element) {
|
|
328
|
-
|
|
629
|
+
Then(/^(I|we)* should see (a|an) "([^"]*)?" element$/, function (pronoundCase, aAnCase, element) {
|
|
630
|
+
const elementField = browser.element.findByText(element, { exact: true });
|
|
631
|
+
browser.getAttribute(elementField, 'for', function (eleAttribute) {
|
|
632
|
+
return browser.verify.visible('#' + eleAttribute.value);
|
|
633
|
+
});
|
|
329
634
|
});
|
|
330
635
|
|
|
331
636
|
/**
|
|
332
|
-
* Assert, that element
|
|
333
|
-
* Example: Then I should
|
|
334
|
-
*
|
|
637
|
+
* Assert, that element exists on the current page by its attribute
|
|
638
|
+
* Example: Then I should see a "uname" element by its "id" attr
|
|
639
|
+
* Example: Then I should see a "pwordcss" element by attr
|
|
640
|
+
*
|
|
335
641
|
*/
|
|
336
|
-
Then(/^(I|we)* should
|
|
337
|
-
|
|
642
|
+
Then(/^(I|we)* should see (a|an) "([^"]*)?" element by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, aAnCase, attrValue, itsCase, attr, attrCase) {
|
|
643
|
+
|
|
644
|
+
const hasASpace = attrValue.indexOf(' ');
|
|
645
|
+
|
|
646
|
+
var selector = '';
|
|
647
|
+
if (!attr && hasASpace == -1){
|
|
648
|
+
selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "]," + '[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
649
|
+
}
|
|
650
|
+
else if (!attr && hasASpace > -1){
|
|
651
|
+
selector ='[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
654
|
+
selector = '[' + attr + '="' + attrValue + '"]';
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
return browser.verify.visible(selector);
|
|
338
658
|
});
|
|
339
659
|
|
|
340
660
|
/**
|
|
341
|
-
* Assert, that element
|
|
661
|
+
* Assert, that element exists on current page by its label
|
|
342
662
|
* Example: Then I should not see a "Username" element
|
|
343
663
|
*
|
|
344
664
|
*/
|
|
345
|
-
Then(/^(I|we)* should not see a "([^"]*)?" element$/, function (pronoundCase, element) {
|
|
346
|
-
|
|
665
|
+
Then(/^(I|we)* should not see (a|an) "([^"]*)?" element$/, function (pronoundCase, aAnCase, element) {
|
|
666
|
+
|
|
667
|
+
browser.assert.not.textContains("html", element);
|
|
347
668
|
});
|
|
348
669
|
|
|
349
670
|
/**
|
|
350
|
-
* Assert, that element exists on current page
|
|
351
|
-
* Example: Then I should not see an "
|
|
671
|
+
* Assert, that element exists on current page by its attributes
|
|
672
|
+
* Example: Then I should not see an "emailId" element by its "id" attr
|
|
673
|
+
* Example: And I should not see a "countryCss" element by attr
|
|
352
674
|
*
|
|
353
675
|
*/
|
|
354
|
-
Then(/^(I|we)* should not see an "([^"]*)?" element$/, function (pronoundCase,
|
|
355
|
-
|
|
676
|
+
Then(/^(I|we)* should not see (a|an) "([^"]*)?" element by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, aAnCase, attrValue, itsCase, attr, attrCase) {
|
|
677
|
+
|
|
678
|
+
const hasASpace = attrValue.indexOf(' ');
|
|
679
|
+
|
|
680
|
+
var selector = '';
|
|
681
|
+
if (!attr && hasASpace == -1){
|
|
682
|
+
selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "]," + '[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
683
|
+
}
|
|
684
|
+
else if (!attr && hasASpace > -1){
|
|
685
|
+
selector ='[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
686
|
+
}
|
|
687
|
+
else {
|
|
688
|
+
selector = '[' + attr + '="' + attrValue + '"]';
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
return browser.expect.element(selector).to.not.be.present;
|
|
356
692
|
});
|
|
357
693
|
|
|
358
694
|
/**
|
|
@@ -360,7 +696,20 @@ Then(/^(I|we)* should not see an "([^"]*)?" element$/, function (pronoundCase, e
|
|
|
360
696
|
* Example: Then the "body" element should contain "color:white;"
|
|
361
697
|
*
|
|
362
698
|
*/
|
|
363
|
-
Then(/^the "([^"]*)?" element should contain "([^"]*)?"$/, function (
|
|
699
|
+
Then(/^the "([^"]*)?" element should contain "([^"]*)?" css style$/, function (attrValue, elementCss) {
|
|
700
|
+
|
|
701
|
+
const hasASpace = attrValue.indexOf(' ');
|
|
702
|
+
|
|
703
|
+
var selector = '';
|
|
704
|
+
if((attrValue.startsWith('#') || attrValue.startsWith('.')) && hasASpace == -1){
|
|
705
|
+
selector = attrValue;
|
|
706
|
+
}
|
|
707
|
+
else if (hasASpace == -1){
|
|
708
|
+
selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "]," + '[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
709
|
+
}
|
|
710
|
+
else if (hasASpace > -1){
|
|
711
|
+
selector ='[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
712
|
+
}
|
|
364
713
|
|
|
365
714
|
elementCss = elementCss.replace(";", '');
|
|
366
715
|
const cssPropertyArr = elementCss.split(":");
|
|
@@ -369,16 +718,30 @@ Then(/^the "([^"]*)?" element should contain "([^"]*)?"$/, function (element, el
|
|
|
369
718
|
const propertyVal = cssPropertyArr[1].trim();
|
|
370
719
|
|
|
371
720
|
this.checkCss = function (browser) {
|
|
372
|
-
browser.assert.cssProperty(
|
|
721
|
+
browser.assert.cssProperty(selector, cssProperty, propertyVal);
|
|
373
722
|
};
|
|
374
723
|
});
|
|
375
724
|
|
|
376
725
|
/**
|
|
377
726
|
* Assert, that element contains a specific CSS style
|
|
378
|
-
* Example: Then the "body" element should not contain "color:white;"
|
|
379
|
-
*
|
|
727
|
+
* Example: Then the "body" element should not contain "color:white;" css style
|
|
728
|
+
* Example: Then the "#uname" element should not contain "border:solid 5px red;" css style
|
|
729
|
+
* Example: Then the "pword" element should not contain "font-size: 26px;" css style
|
|
380
730
|
*/
|
|
381
|
-
Then(/^the "([^"]*)?" element should not contain "([^"]*)?"$/, function (
|
|
731
|
+
Then(/^the "([^"]*)?" element should not contain "([^"]*)?" css style$/, function (attrValue, elementCss) {
|
|
732
|
+
|
|
733
|
+
const hasASpace = attrValue.indexOf(' ');
|
|
734
|
+
|
|
735
|
+
var selector = '';
|
|
736
|
+
if((attrValue.startsWith('#') || attrValue.startsWith('.')) && hasASpace == -1){
|
|
737
|
+
selector = attrValue;
|
|
738
|
+
}
|
|
739
|
+
else if (hasASpace == -1){
|
|
740
|
+
selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "]," + '[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
741
|
+
}
|
|
742
|
+
else if (hasASpace > -1){
|
|
743
|
+
selector ='[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
|
|
744
|
+
}
|
|
382
745
|
|
|
383
746
|
elementCss = elementCss.replace(";", '');
|
|
384
747
|
const cssPropertyArr = elementCss.split(":");
|
|
@@ -387,7 +750,7 @@ Then(/^the "([^"]*)?" element should not contain "([^"]*)?"$/, function (element
|
|
|
387
750
|
const propertyVal = cssPropertyArr[1].trim();
|
|
388
751
|
|
|
389
752
|
this.checkCss = function (browser) {
|
|
390
|
-
browser.assert.not.cssProperty(
|
|
753
|
+
browser.assert.not.cssProperty(selector, cssProperty, propertyVal);
|
|
391
754
|
};
|
|
392
755
|
});
|
|
393
756
|
|