webship-js 1.0.35 → 1.0.39

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.
@@ -27,6 +27,7 @@ module.exports = {
27
27
  selenium_port: 4444,
28
28
  selenium_host: '127.0.0.1',
29
29
  silent: true,
30
+ output: false,
30
31
  screenshots: {
31
32
  enabled: false,
32
33
  path: './reports/screenshots',
@@ -37,6 +37,7 @@ module.exports = {
37
37
  selenium_port: 4444,
38
38
  selenium_host: '127.0.0.1',
39
39
  silent: true,
40
+ output: false,
40
41
  screenshots: {
41
42
  enabled: true,
42
43
  path: './reports/screenshots',
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset='utf-8'>
5
+ <title>Click Link</title>
6
+ <style>
7
+ .style {
8
+ font-size: 26px;
9
+ }
10
+ </style>
11
+ </head>
12
+ <body>
13
+ <h1>Click Link</h1>
14
+ <div id="result" class="style">
15
+ <ul>
16
+ <li><a id="aboutUsid" class="aboutUs" title="aboutUsTitle" href="about-us.html">About us</a></li>
17
+ <li><a id="contactUsid" class="contactUs" href="contact-us.html">Contact us</a></li>
18
+ </ul>
19
+ </div>
20
+ </body>
21
+ </html>
@@ -0,0 +1,49 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <meta charset='utf-8'>
6
+ <title>when I scroll to the bottom</title>
7
+ <style>
8
+ .container,
9
+ .container input,
10
+ .container button {
11
+ font-size: 26px;
12
+ }
13
+
14
+ .style {
15
+ font-size: 22px;
16
+ line-height: 30px;
17
+ border-width: 1pc;
18
+ }
19
+
20
+ #complete{
21
+ font-size: 32px;
22
+ line-height: 30px;
23
+ }
24
+
25
+ </style>
26
+
27
+ </head>
28
+
29
+ <body>
30
+ <h1>scrolling page to the bottom</h1>
31
+
32
+ <div id="container">
33
+
34
+ </div>
35
+
36
+ <div id="complete">
37
+
38
+ </div>
39
+ </body>
40
+
41
+ <script>
42
+
43
+ for(var i=0; i<20; i++){
44
+ document.getElementById("container").innerHTML += '<p class="style"> Container #' + i + '</p>';
45
+ }
46
+ document.getElementById("complete").innerHTML += "Scrolling has reached the bottom";
47
+
48
+ </script>
49
+ </html>
@@ -27,6 +27,7 @@ module.exports = {
27
27
  selenium_port: 4444,
28
28
  selenium_host: '127.0.0.1',
29
29
  silent: true,
30
+ output: false,
30
31
  screenshots: {
31
32
  enabled: true,
32
33
  path: './reports/screenshots',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webship-js",
3
- "version": "1.0.35",
3
+ "version": "1.0.39",
4
4
  "description": "Webship JS automated functional testing.",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -7,4 +7,4 @@ Feature: An example to verify whether the element does not contain a specific ex
7
7
  Then I should see a "body" element by attr
8
8
  When I press "Submit"
9
9
  Then the "#uname" element should not contain "border:solid 5px red;"
10
- And the "pword" element should not contain "font-size: 28px;"
10
+ And the "pword" element should not contain "font-size: 28px;"
@@ -4,4 +4,4 @@ Feature: An example of checking for matching URLs based on a specific pattern
4
4
 
5
5
  Scenario: Ensure that the current page path matches the URL pattern that uses dashes between words
6
6
  Given I am on "/test-acceptable-url-path.html"
7
- Then the url should match "(https?:\/\/)?([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^?#\s_]+)?(\?[^#\s_]+)?(#.*)?"
7
+ Then the url should match "(https?:\/\/)?([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.[a-zA-Z]{2,}(:\d+)?(\/[^?#\s_]+)?(\?[^#\s_]+)?(#.*)?"
@@ -0,0 +1,19 @@
1
+ Feature: An example of checking the href attribute of a link element to see if it contains a specific URL, which is found by its attributes.
2
+
3
+ As a tester,
4
+ I want to be able to check link href if contain a specific URL found by its attributes
5
+
6
+ Scenario: Verify that the link contains "about" by its direct id, class attribute
7
+ Given I am on "/test--then--the-link-should-contain.html"
8
+ Then the "#aboutUsid" link should contain "about" by attr
9
+ And the ".contactUs" link should contain "/contact-" by attr
10
+
11
+ Scenario: Verify that the link contains "contact-" by its id, class attribute
12
+ Given I am on "/test--then--the-link-should-contain.html"
13
+ Then the "contactUsid" link should contain "/contact-" by its "id" attribute
14
+ And the "aboutUs" link should contain "about" by its "class" attribute
15
+
16
+ Scenario: Verify that the link contains "about" by its "Title" attribute
17
+ Given I am on "/test--then--the-link-should-contain.html"
18
+ Then the "aboutUsTitle" link should contain "about-us" by attr
19
+ And the "aboutUsTitle" link should contain "about-us" by its "title" attribute
@@ -0,0 +1,8 @@
1
+ Feature: An example of checking the href attribute of a link element to see if it contains a specific text.
2
+
3
+ As a tester,
4
+ I want to be able to check link href if contain a specific text
5
+
6
+ Scenario: Verify that the link contains "about"
7
+ Given I am on "/test--then--the-link-should-contain.html"
8
+ Then the "About us" link should contain "about"
@@ -5,6 +5,6 @@ Feature: An example of clicking a link by its text
5
5
 
6
6
  Scenario: Verify clicking a link by its text
7
7
  Given I am on "/test--when--i-click-link.html"
8
- When I click "About us link"
8
+ When I click "About us link"
9
9
  And I wait max of 2 seconds
10
- Then I should see "About Us"
10
+ Then I should see "About Us"
@@ -4,17 +4,17 @@ Feature: An example of filling an input textbox with a value using its attribute
4
4
 
5
5
  Scenario: Fill in the input field using its ID and class attributes.
6
6
  Given I am on "/test--when--i-fill-in.html"
7
- When I fill in "#uname" with "John Smith" by attr
7
+ When I fill in "#uname" with "John Smith" by attr
8
8
  And I fill in "pwordcss" with "1234" by its "class" attr
9
- When I press "Login"
10
- Then I should see "You enter Username: John Smith and Password: 1234"
9
+ When I press "Login"
10
+ Then I should see "You enter Username: John Smith and Password: 1234"
11
11
 
12
12
  Scenario: Fill in the input field using its placeholder attribute.
13
13
  Given I am on "/test--when--i-fill-in.html"
14
- When I fill in "Your full name" with "John Smith" by its "placeholder" attr
14
+ When I fill in "Your full name" with "John Smith" by its "placeholder" attr
15
15
  And I fill in "Your Password" with "1234" by attr
16
- When I press "Login"
17
- Then I should see "You enter Username: John Smith and Password: 1234"
16
+ When I press "Login"
17
+ Then I should see "You enter Username: John Smith and Password: 1234"
18
18
 
19
19
  Scenario: Specify a value, then identify and use the field's attribute to fill in the input field.
20
20
  Given I am on "/test--when--i-fill-in.html"
@@ -26,6 +26,6 @@ Feature: An example of filling an input textbox with a value using its attribute
26
26
  Scenario: Fill in the input field with an empty value using its attribute.
27
27
  Given I am on "/test--when--i-fill-in.html"
28
28
  When I fill in "#uname" with: by attribute
29
- And I fill in "password" with: by attr
29
+ And I fill in "password" with: by attr
30
30
  When I press "Login" by attr
31
31
  Then I should see "You enter Username: and Password:"
@@ -19,7 +19,7 @@ Feature: An example of filling an input textbox with a value using its label.
19
19
  Scenario: Check filling an input field with an empty value using its label.
20
20
  Given I am on "/test--when--i-fill-in.html"
21
21
  When I fill in "Username" with:
22
- And I fill in "Password" with:
22
+ And I fill in "Password" with:
23
23
  When I press "Login"
24
24
  Then I should see "You enter Username: and Password:"
25
25
 
@@ -5,15 +5,15 @@ Feature: An example of pressing a button using its attributes.
5
5
 
6
6
  Scenario: Verify that you can click a button by specifying its ID with the '#' sign.
7
7
  Given I am on "/test--when--i-press-button.html"
8
- When I press "#btn-pressid" by attr
9
- Then I should see "Button Pressed Successfully"
8
+ When I press "#btn-pressid" by attr
9
+ Then I should see "Button Pressed Successfully"
10
10
 
11
11
  Scenario: Verify that you can click a button by specifying the 'ID' attribute without the '#' sign.
12
12
  Given I am on "/test--when--i-press-button.html"
13
- When I press "btn-pressid" by "id" attr
14
- Then I should see "Button Pressed Successfully"
13
+ When I press "btn-pressid" by "id" attr
14
+ Then I should see "Button Pressed Successfully"
15
15
 
16
16
  Scenario: Verify that you can click a button without specifying any attributes or signs, using only the value of one of its attributes.
17
17
  Given I am on "/test--when--i-press-button.html"
18
- When I press "btn-pressname" by attr
19
- Then I should see "Button Pressed Successfully"
18
+ When I press "btn-pressname" by attr
19
+ Then I should see "Button Pressed Successfully"
@@ -0,0 +1,9 @@
1
+ Feature: An example test Scrolling page to the bottom.
2
+
3
+ As a tester,
4
+ I want to make sure that I can arrive the bottom of the current page.
5
+
6
+ Scenario: Check Scrolling page to the bottom.
7
+ Given I am on "/test--when--i-scroll-to-the-bottom.html"
8
+ When I scroll to the bottom
9
+ Then I should see "Scrolling has reached the bottom"
@@ -5,6 +5,6 @@ Feature: An example of selecting an option in the dropdown list by its text labe
5
5
 
6
6
  Scenario: Check selecting an option from a dropdown list by its text label.
7
7
  Given I am on "/test--when--i-select-option-from-dropdownlist.html"
8
- When I select "Saab" from "Choose a car:"
9
- When I press "Submit" by attr
10
- Then I should see "Option ( Saab ) has been selected successfully"
8
+ When I select "Saab" from "Choose a car:"
9
+ When I press "Submit" by attr
10
+ Then I should see "Option ( Saab ) has been selected successfully"
@@ -5,12 +5,18 @@ Feature: An example test to wait for a specific maximum number of seconds/minute
5
5
 
6
6
  Scenario: Check waiting 6 seconds for the page content to load.
7
7
  Given I am on the homepage
8
- When I go to "/test--when-i-wait-specific-time.html"
9
- And I wait 6 seconds
10
- Then I should see "Welcome with waiting full time"
8
+ When I go to "/test--when-i-wait-specific-time.html"
9
+ And I wait 6 seconds
10
+ Then I should see "Welcome with waiting full time"
11
11
 
12
- Scenario: Check waiting a maximum of 6 seconds for the page content to load.
12
+ Scenario: Check waiting 3s for the page content to load.
13
13
  Given I am on the homepage
14
- When I go to "/test--when-i-wait-max-of-time.html"
15
- And I wait max of 6 seconds
16
- Then I should see "Welcome with waiting until page load"
14
+ When I go to "/test--when-i-wait-specific-time.html"
15
+ And I wait 3s
16
+ Then I should see "Welcome with waiting full time"
17
+
18
+ Scenario: Check waiting a maximum of 6 seconds for the page content to load.
19
+ Given I am on the homepage
20
+ When I go to "/test--when-i-wait-max-of-time.html"
21
+ And I wait max of 6 seconds
22
+ Then I should see "Welcome with waiting until page load"
@@ -4,22 +4,15 @@ const { Then} = require('@cucumber/cucumber');
4
4
 
5
5
  const axios = require('axios');
6
6
 
7
- /**
8
- * Opens homepage.
9
- * Example: Given I am on homepage
10
- *
11
- */
12
- Given(/^(I am|we are) on homepage$/, function (pronoundCase) {
13
- return browser.url(browser.launch_url);
14
- });
15
7
 
16
8
  /**
17
9
  * Opens homepage.
10
+ * Example: Given I am on homepage
18
11
  * Example: Given I am on the homepage
19
12
  *
20
13
  */
21
- Given(/^(I am|we are) on the homepage$/, function (pronoundCase) {
22
- return browser.url(browser.launch_url);
14
+ Given(/^(I am|we are) on( the)* homepage$/, function (pronoundCase, theCase) {
15
+ return browser.url(browser.launch_url).waitForElementPresent('body', 1000);
23
16
  });
24
17
 
25
18
  /**
@@ -28,17 +21,7 @@ Given(/^(I am|we are) on the homepage$/, function (pronoundCase) {
28
21
  *
29
22
  */
30
23
  Given(/^(I am|we are) on "([^"]*)?"$/, function (pronoundCase, url) {
31
- return browser.url(browser.launch_url + url);
32
- });
33
-
34
- /**
35
- * Go to homepage
36
- * Example: When I go to homepage
37
- * Example: And I go to "/"
38
- *
39
- */
40
- When(/^(I|we)* go to homepage$/, function (pronoundCase) {
41
- return browser.url(browser.launch_url);
24
+ return browser.url(browser.launch_url + url).waitForElementPresent('body', 1000);
42
25
  });
43
26
 
44
27
  /**
@@ -47,8 +30,8 @@ When(/^(I|we)* go to homepage$/, function (pronoundCase) {
47
30
  * Example: And I go to the "/"
48
31
  *
49
32
  */
50
- When(/^(I|we)* go to the homepage$/, function (pronoundCase) {
51
- return browser.url(browser.launch_url);
33
+ When(/^(I|we)* go to( the)* homepage$/, function (pronoundCase, theCase) {
34
+ return browser.url(browser.launch_url).waitForElementPresent('body', 1000);
52
35
  });
53
36
 
54
37
  /**
@@ -57,7 +40,7 @@ When(/^(I|we)* go to the homepage$/, function (pronoundCase) {
57
40
  *
58
41
  */
59
42
  When(/^(I|we)* go to "([^"]*)?"$/, function (pronoundCase, url) {
60
- return browser.url(browser.launch_url + url);
43
+ return browser.url(browser.launch_url + url).waitForElementPresent('body', 1000);
61
44
  });
62
45
 
63
46
  /**
@@ -68,7 +51,9 @@ When(/^(I|we)* go to "([^"]*)?"$/, function (pronoundCase, url) {
68
51
  *
69
52
  */
70
53
  Then(/^(I|we)* should see "([^"]*)?"$/, function (pronoundCase, expectedText) {
54
+ return this.shouldSee = function (browser) {
71
55
  browser.assert.textContains("html", expectedText);
56
+ };
72
57
  });
73
58
 
74
59
  /**
@@ -79,7 +64,9 @@ Then(/^(I|we)* should see "([^"]*)?"$/, function (pronoundCase, expectedText) {
79
64
  *
80
65
  */
81
66
  Then(/^(I|we)* should not see "([^"]*)?"$/, function (pronoundCase, expectedText) {
67
+ return this.shouldSee = function (browser) {
82
68
  browser.assert.not.textContains("html", expectedText);
69
+ };
83
70
  });
84
71
 
85
72
  /**
@@ -197,7 +184,7 @@ When(/^(I|we)* reload page$/, function (pronoundCase) {
197
184
  * Example: And I reload the page
198
185
  *
199
186
  */
200
- When(/^(I|we)* reload the page$/, function (pronoundCase) {
187
+ When(/^(I|we)* reload( the)* page$/, function (pronoundCase, theCase) {
201
188
  return browser.refresh(browser.getCurrentUrl());
202
189
  });
203
190
 
@@ -208,7 +195,7 @@ When(/^(I|we)* reload the page$/, function (pronoundCase) {
208
195
  *
209
196
  */
210
197
  When(/^(I|we)* fill in "([^"]*)?" with "([^"]*)?"$/, function (pronoundCase, field, value) {
211
- const elementField = browser.element.findByText(field);
198
+ const elementField = browser.element.findByText(field, { exact: true });
212
199
  browser.getAttribute(elementField, 'for', function (eleAttribute) {
213
200
  return browser.setValue('#' + eleAttribute.value, value);
214
201
  });
@@ -250,7 +237,7 @@ When(/^(I|we)* fill in "([^"]*)?" with "([^"]*)?" by( its)*( "([^"]*)?")* (attri
250
237
  *
251
238
  */
252
239
  When(/^(I|we)* fill in "([^"]*)?" with:$/, function (pronoundCase, field) {
253
- const elementField = browser.element.findByText(field);
240
+ const elementField = browser.element.findByText(field, { exact: true });
254
241
  browser.getAttribute(elementField, 'for', function (eleAttribute) {
255
242
  return browser.setValue('#' + eleAttribute.value, '');
256
243
  });
@@ -291,7 +278,7 @@ When(/^(I|we)* fill in "([^"]*)?" with: by( its)*( "([^"]*)?")* (attribute|attr)
291
278
  *
292
279
  */
293
280
  When(/^(I|we)* fill in "([^"]*)?" for "([^"]*)?"$/, function (pronoundCase, value, field) {
294
- const elementField = browser.element.findByText(field);
281
+ const elementField = browser.element.findByText(field, { exact: true });
295
282
  browser.getAttribute(elementField, 'for', function (eleAttribute) {
296
283
  return browser.setValue('#' + eleAttribute.value, value);
297
284
  });
@@ -334,16 +321,16 @@ When(/^(I|we)* fill in "([^"]*)?" for "([^"]*)?" by( its)*( "([^"]*)?")* (attrib
334
321
  * | Password | 1234 |
335
322
  */
336
323
 
337
- When(/^(I|we)* fill in the following:$/, function (pronoundCase, table) {
324
+ When(/^(I|we)* fill in( the)* following:$/, function (pronoundCase, theCase, table) {
338
325
 
339
- var elementField = browser.element.findByText(table.rawTable[0][0]);
326
+ var elementField = browser.element.findByText(table.rawTable[0][0], { exact: true });
340
327
  browser.getAttribute(elementField, 'for', function (eleAttribute) {
341
328
  browser.setValue('#' + eleAttribute.value, table.rawTable[0][1]);
342
329
  });
343
330
 
344
331
  table.rows().forEach(row => {
345
332
 
346
- elementField = browser.element.findByText(row[0]);
333
+ elementField = browser.element.findByText(row[0], { exact: true });
347
334
  browser.getAttribute(elementField, 'for', function (eleAttribute2) {
348
335
  browser.setValue('#' + eleAttribute2.value, row[1]);
349
336
  });
@@ -361,7 +348,7 @@ When(/^(I|we)* fill in the following:$/, function (pronoundCase, table) {
361
348
  * | Your Password | 1234 |
362
349
  */
363
350
 
364
- When(/^(I|we)* fill in the following: by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, itsCase, attr, attrCase, table) {
351
+ When(/^(I|we)* fill in( the)* following: by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, theCase, itsCase, attr, attrCase, table) {
365
352
 
366
353
  var hasASpace = table.rawTable[0][0].indexOf(' ');
367
354
  var selector = '';
@@ -413,11 +400,11 @@ When(/^(I|we)* fill in the following: by( its)*( "([^"]*)?")* (attribute|attr)$/
413
400
  */
414
401
  When(/^(I|we)* select "([^"]*)?" from "([^"]*)?"$/, function (pronoundCase, option, dropdownlist) {
415
402
 
416
- const elementField = browser.element.findByText(dropdownlist);
403
+ const elementField = browser.element.findByText(dropdownlist, { exact: true });
417
404
  browser.getAttribute(elementField, 'for', function (eleAttribute) {
418
405
  return browser.waitForElementVisible('css selector', '#' + eleAttribute.value)
419
406
  .click('#' + eleAttribute.value)
420
- .click(browser.element.findByText(option))
407
+ .click(browser.element.findByText(option, { exact: true }))
421
408
  .click('#' + eleAttribute.value);
422
409
  });
423
410
  });
@@ -449,7 +436,7 @@ When(/^(I|we)* select "([^"]*)?" from "([^"]*)?" by( its)*( "([^"]*)?")* (attrib
449
436
 
450
437
  return browser.waitForElementVisible('css selector', selector)
451
438
  .click(selector)
452
- .click(browser.element.findByText(option))
439
+ .click(browser.element.findByText(option, { exact: true }))
453
440
  .click(selector);
454
441
  });
455
442
 
@@ -476,18 +463,10 @@ When(/^(I|we)* uncheck "([^"]*)?"$/, function (pronoundCase, item) {
476
463
  /**
477
464
  * Verify, that current page is the homepage
478
465
  * Example: Then I should be on homepage
479
- *
480
- */
481
- Then(/^(I|we)* should be on homepage$/, function (pronoundCase) {
482
- return browser.assert.urlMatches(browser.launch_url);
483
- });
484
-
485
- /**
486
- * Verify, that current page is the homepage
487
466
  * Example: Then I should be on the homepage
488
467
  *
489
468
  */
490
- Then(/^(I|we)* should be on the homepage$/, function (pronoundCase) {
469
+ Then(/^(I|we)* should be on( the)* homepage$/, function (pronoundCase, theCase) {
491
470
  return browser.assert.urlMatches(browser.launch_url);
492
471
  });
493
472
 
@@ -505,7 +484,7 @@ Then(/^(I|we)* should not be on homepage$/, function (pronoundCase) {
505
484
  * Example: Then I should not be on the homepage
506
485
  *
507
486
  */
508
- Then(/^(I|we)* should not be on the homepage$/, function (pronoundCase) {
487
+ Then(/^(I|we)* should not be on( the)* homepage$/, function (pronoundCase, theCase) {
509
488
  return browser.assert.not.urlMatches(browser.launch_url);
510
489
  });
511
490
 
@@ -516,16 +495,55 @@ Then(/^(I|we)* should not be on the homepage$/, function (pronoundCase) {
516
495
  * Example: And I should be on "http://google.com"
517
496
  *
518
497
  */
498
+
519
499
  Then(/^(I|we)* should be on "([^"]*)?"$/, function (pronoundCase, url) {
520
500
  return browser.assert.urlContains(url);
521
501
  });
522
502
 
503
+ /**
504
+ * Verify, that the current link contains the specified URL.
505
+ * Example: Then the "Login" link should contain "/log-in"
506
+ *
507
+ */
508
+ Then(/^(the )*"([^"]*)?" link should contain "([^"]*)?"$/, function (theCase, element, url) {
509
+ const elementField = browser.element.findByText(element, { exact: true });
510
+ return browser.assert.attributeContains(elementField, 'href', url);
511
+ });
512
+
513
+ /**
514
+ * Verify, that the current link contains the specified URL, found by its attributes.
515
+ * Example: Then the "#aboutUsid" link should contain "about" by attr
516
+ * Example: And the "aboutUs" link should contain "about" by its "class" attribute
517
+ * Example: And the ".contactUs" link should contain "/contact-" by attr
518
+ *
519
+ */
520
+ Then(/^(the )*"([^"]*)?" link should contain "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (theCase, attrValue, url, itsCase, attr, attrCase) {
521
+
522
+ const hasASpace = attrValue.indexOf(' ');
523
+ var selector = '';
524
+
525
+ if((attrValue.startsWith('#') || attrValue.startsWith('.')) && hasASpace == -1){
526
+ selector = attrValue;
527
+ }
528
+ else if (!attr && hasASpace == -1){
529
+ selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "]," + '[value="' + attrValue + '"],[placeholder="' + attrValue + '"],' + '[title="' + attrValue + '"]';
530
+ }
531
+ else if (!attr && hasASpace > -1){
532
+ selector ='[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
533
+ }
534
+ else {
535
+ selector = '[' + attr + '="' + attrValue + '"]';
536
+ }
537
+
538
+ return browser.assert.attributeContains(selector, 'href', url);
539
+ });
540
+
523
541
  /**
524
542
  * Checks, that HTML response contains specific text
525
543
  * Example: Then the response should contain "Welcome visitor, How can I help you?"
526
544
  *
527
545
  */
528
- Then(/^the response should contain "([^"]*)?"$/, function (expectedText) {
546
+ Then(/^(the )*response should contain "([^"]*)?"$/, function (theCase, expectedText) {
529
547
  return this.shouldSee = function (browser) {
530
548
  browser.assert.textContains("html", expectedText);
531
549
  };
@@ -536,7 +554,7 @@ Then(/^the response should contain "([^"]*)?"$/, function (expectedText) {
536
554
  * Example: Then the response should not contain "Error: Ambiguous messages that are unclear"
537
555
  *
538
556
  */
539
- Then(/^the response should not contain "([^"]*)?"$/, function (expectedText) {
557
+ Then(/^(the )*response should not contain "([^"]*)?"$/, function (theCase, expectedText) {
540
558
  return this.shouldSee = function (browser) {
541
559
  browser.assert.not.textContains("html", expectedText);
542
560
  };
@@ -548,8 +566,8 @@ Then(/^the response should not contain "([^"]*)?"$/, function (expectedText) {
548
566
  * Example: Then I should see "John Smith" in the "Username" element
549
567
  *
550
568
  */
551
- Then(/^(I|we)* should see "([^"]*)?" in the "([^"]*)?" element$/, function (pronoundCase, expectedText, element) {
552
- const elementField = browser.element.findByText(element);
569
+ Then(/^(I|we)* should see "([^"]*)?" in( the)* "([^"]*)?" element$/, function (pronoundCase, expectedText,theCase , element) {
570
+ const elementField = browser.element.findByText(element, { exact: true });
553
571
  browser.getAttribute(elementField, 'for', function (eleAttribute) {
554
572
  return this.shouldSee = function (browser) {
555
573
  browser.assert.textContains('#' + eleAttribute.value, expectedText);
@@ -563,7 +581,7 @@ Then(/^(I|we)* should see "([^"]*)?" in the "([^"]*)?" element$/, function (pron
563
581
  * Example: Then I should see "1234" in the "pwordcss" element by attr
564
582
  *
565
583
  */
566
- Then(/^(I|we)* should see "([^"]*)?" in the "([^"]*)?" element by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, expectedText, attrValue, itsCase, attr, attrCase) {
584
+ Then(/^(I|we)* should see "([^"]*)?" in( the)* "([^"]*)?" element by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, expectedText, theCase, attrValue, itsCase, attr, attrCase) {
567
585
 
568
586
  const hasASpace = attrValue.indexOf(' ');
569
587
 
@@ -588,9 +606,9 @@ Then(/^(I|we)* should see "([^"]*)?" in the "([^"]*)?" element by( its)*( "([^"]
588
606
  * Example: Then I should not see "Joe Smith" in the "Username" element
589
607
  *
590
608
  */
591
- Then(/^(I|we)* should not see "([^"]*)?" in the "([^"]*)?" element$/, function (pronoundCase, expectedText, element) {
609
+ Then(/^(I|we)* should not see "([^"]*)?" in( the)* "([^"]*)?" element$/, function (pronoundCase, expectedText, theCase, element) {
592
610
 
593
- const elementField = browser.element.findByText(element);
611
+ const elementField = browser.element.findByText(element, { exact: true });
594
612
  browser.getAttribute(elementField, 'for', function (eleAttribute) {
595
613
  return this.shouldSee = function (browser) {
596
614
  browser.assert.not.textContains('#' + eleAttribute.value, expectedText);
@@ -604,7 +622,7 @@ Then(/^(I|we)* should not see "([^"]*)?" in the "([^"]*)?" element$/, function (
604
622
  * Example: Then I should not see "1234" in the "pwordcss" element by attr
605
623
  *
606
624
  */
607
- Then(/^(I|we)* should not see "([^"]*)?" in the "([^"]*)?" element by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, expectedText, attrValue, itsCase, attr, attrCase) {
625
+ Then(/^(I|we)* should not see "([^"]*)?" in( the)* "([^"]*)?" element by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, expectedText, theCase, attrValue, itsCase, attr, attrCase) {
608
626
 
609
627
  const hasASpace = attrValue.indexOf(' ');
610
628
 
@@ -699,7 +717,7 @@ Then(/^(I|we)* should not see (a|an) "([^"]*)?" element by( its)*( "([^"]*)?")*
699
717
  * Example: Then the "body" element should contain "color:white;"
700
718
  *
701
719
  */
702
- Then(/^the "([^"]*)?" element should contain "([^"]*)?"$/, function (selector, elementCss) {
720
+ Then(/^(the )*"([^"]*)?" element should contain "([^"]*)?"$/, function (theCase ,selector, elementCss) {
703
721
 
704
722
  elementCss = elementCss.replace(";", '');
705
723
  const cssPropertyArr = elementCss.split(":");
@@ -718,7 +736,7 @@ Then(/^the "([^"]*)?" element should contain "([^"]*)?"$/, function (selector, e
718
736
  * Example: Then the "#uname" element should not contain "border:solid 5px red;"
719
737
  * Example: Then the "pword" element should not contain "font-size: 26px;"
720
738
  */
721
- Then(/^the "([^"]*)?" element should not contain "([^"]*)?"$/, function (selector, elementCss) {
739
+ Then(/^(the )*"([^"]*)?" element should not contain "([^"]*)?"$/, function (theCase, selector, elementCss) {
722
740
 
723
741
  elementCss = elementCss.replace(";", '');
724
742
  const cssPropertyArr = elementCss.split(":");
@@ -736,7 +754,7 @@ Then(/^the "([^"]*)?" element should not contain "([^"]*)?"$/, function (selecto
736
754
  * Example: When I attach the file "profileIcon.jpg" to "#profileIconUpload"
737
755
  *
738
756
  */
739
- When(/^(I|we)* attach the file "([^"]*)?" to "([^"]*)?"$/, function (pronoundCase, fileUrl, element) {
757
+ When(/^(I|we)* attach( the)* file "([^"]*)?" to "([^"]*)?"$/, function (pronoundCase, theCase, fileUrl, element) {
740
758
  var dirname = __dirname + '';
741
759
  dirname = dirname.substring(0, dirname.lastIndexOf("/"));
742
760
 
@@ -748,9 +766,9 @@ When(/^(I|we)* attach the file "([^"]*)?" to "([^"]*)?"$/, function (pronoundCas
748
766
  * Example: Then the "Username" field should contain "John Smith"
749
767
  *
750
768
  */
751
- Then(/^the "([^"]*)?" field should contain "([^"]*)?"$/, function (field, expectedText) {
769
+ Then(/^(the )*"([^"]*)?" field should contain "([^"]*)?"$/, function (theCase, field, expectedText) {
752
770
 
753
- const elementField = browser.element.findByText(field);
771
+ const elementField = browser.element.findByText(field, { exact: true });
754
772
  browser.getAttribute(elementField, 'for', function (eleAttribute) {
755
773
  return this.shouldSee = function (browser) {
756
774
  browser.assert.textContains('#' + eleAttribute.value, expectedText);
@@ -763,7 +781,7 @@ Then(/^the "([^"]*)?" field should contain "([^"]*)?"$/, function (field, expect
763
781
  * Example: Then the "#username" field should not contain "John Smith"
764
782
  *
765
783
  */
766
- Then(/^the "([^"]*)?" field should not contain "([^"]*)?"$/, function (field, expectedText) {
784
+ Then(/^(the )*"([^"]*)?" field should not contain "([^"]*)?"$/, function (theCase, field, expectedText) {
767
785
 
768
786
  return this.shouldSee = function (browser) {
769
787
  browser.assert.not.textContains(field, expectedText);
@@ -775,7 +793,7 @@ Then(/^the "([^"]*)?" field should not contain "([^"]*)?"$/, function (field, ex
775
793
  * Example: Then the "#PrivacyPolicy" checkbox should be checked
776
794
  *
777
795
  */
778
- Then(/^the "([^"]*)?" checkbox should be checked$/, function (checkbox) {
796
+ Then(/^(the )*"([^"]*)?" checkbox should be checked$/, function (theCase, checkbox) {
779
797
  return browser.expect.element(checkbox).to.be.selected;
780
798
  });
781
799
 
@@ -784,7 +802,7 @@ Then(/^the "([^"]*)?" checkbox should be checked$/, function (checkbox) {
784
802
  * Example: Then the "#PrivacyPolicy" checkbox should not be checked
785
803
  *
786
804
  */
787
- Then(/^the "([^"]*)?" checkbox should not be checked$/, function (checkbox) {
805
+ Then(/^(the )*"([^"]*)?" checkbox should not be checked$/, function (theCase, checkbox) {
788
806
  return browser.expect.element(checkbox).to.not.be.selected;
789
807
  });
790
808
 
@@ -793,7 +811,7 @@ Then(/^the "([^"]*)?" checkbox should not be checked$/, function (checkbox) {
793
811
  * Example: Then the "#rememberMe" checkbox is checked
794
812
  *
795
813
  */
796
- Then(/^the "([^"]*)?" checkbox is checked$/, function (checkbox) {
814
+ Then(/^(the )*"([^"]*)?" checkbox is checked$/, function (theCase, checkbox) {
797
815
  return browser.expect.element(checkbox).to.be.selected;
798
816
  });
799
817
 
@@ -802,7 +820,7 @@ Then(/^the "([^"]*)?" checkbox is checked$/, function (checkbox) {
802
820
  * Example: Then the "#rememberMe" checkbox is not checked
803
821
  *
804
822
  */
805
- Then(/^the "([^"]*)?" checkbox is not checked$/, function (checkbox) {
823
+ Then(/^(the )*"([^"]*)?" checkbox is not checked$/, function (theCase, checkbox) {
806
824
  return browser.expect.element(checkbox).to.not.be.selected;
807
825
  });
808
826
 
@@ -811,7 +829,7 @@ Then(/^the "([^"]*)?" checkbox is not checked$/, function (checkbox) {
811
829
  * Example: Then the checkbox "#PrivacyPolicy" should be checked
812
830
  *
813
831
  */
814
- Then(/^the checkbox "([^"]*)?" should be checked$/, function (checkbox) {
832
+ Then(/^(the )*checkbox "([^"]*)?" should be checked$/, function (theCase, checkbox) {
815
833
  return browser.expect.element(checkbox).to.be.selected;
816
834
  });
817
835
 
@@ -820,7 +838,7 @@ Then(/^the checkbox "([^"]*)?" should be checked$/, function (checkbox) {
820
838
  * Example: Then the checkbox "#PrivacyPolicy" should not be checked
821
839
  *
822
840
  */
823
- Then(/^the checkbox "([^"]*)?" should not be checked$/, function (checkbox) {
841
+ Then(/^(the )*checkbox "([^"]*)?" should not be checked$/, function (theCase, checkbox) {
824
842
  return browser.expect.element(checkbox).to.not.be.selected;
825
843
  });
826
844
 
@@ -829,7 +847,7 @@ Then(/^the checkbox "([^"]*)?" should not be checked$/, function (checkbox) {
829
847
  * Example: Then the checkbox "#rememberMe" is checked
830
848
  *
831
849
  */
832
- Then(/^the checkbox "([^"]*)?" is checked$/, function (checkbox) {
850
+ Then(/^(the )*checkbox "([^"]*)?" is checked$/, function (theCase, checkbox) {
833
851
  return browser.expect.element(checkbox).to.be.selected;
834
852
  });
835
853
 
@@ -838,7 +856,7 @@ Then(/^the checkbox "([^"]*)?" is checked$/, function (checkbox) {
838
856
  * Example: Then the checkbox "#rememberMe" is not checked
839
857
  *
840
858
  */
841
- Then(/^the checkbox "([^"]*)?" is not checked$/, function (checkbox) {
859
+ Then(/^(the )*checkbox "([^"]*)?" is not checked$/, function (theCase, checkbox) {
842
860
  return browser.expect.element(checkbox).to.not.be.selected;
843
861
  });
844
862
 
@@ -846,9 +864,10 @@ Then(/^the checkbox "([^"]*)?" is not checked$/, function (checkbox) {
846
864
  * Wait a specific number of seconds.
847
865
  * Example: When I wait 1 second
848
866
  * Example: When I wait 5 seconds
867
+ * Example: When I wait 3s
849
868
  *
850
869
  */
851
- When(/^(I|we)* wait (\d*) second(s)*$/, function (pronoundCase, number, withS) {
870
+ When(/^(I|we)* wait (\d*)( second)*(s)*$/, function (pronoundCase, number, withWord, withS) {
852
871
  var waitTime = number * 1000;
853
872
  return browser.pause(waitTime);
854
873
  });
@@ -858,7 +877,7 @@ When(/^(I|we)* wait (\d*) second(s)*$/, function (pronoundCase, number, withS) {
858
877
  * Example: When I wait max of 6 seconds
859
878
  *
860
879
  */
861
- When(/^(I|we)* wait max of (\d*) second(s)*$/, function (pronoundCase, number, withS) {
880
+ When(/^(I|we)* wait max of (\d*)( second)*(s)*$/, function (pronoundCase, number, withWord, withS) {
862
881
  var waitTime = number * 1000;
863
882
  return browser.waitForElementPresent('body', waitTime);
864
883
  });
@@ -869,7 +888,7 @@ When(/^(I|we)* wait max of (\d*) second(s)*$/, function (pronoundCase, number, w
869
888
  * Example: When I wait 5 minutes
870
889
  *
871
890
  */
872
- When(/^(I|we)* wait (\d*) minute(s)*$/, function (pronoundCase, number, withS) {
891
+ When(/^(I|we)* wait (\d*)( minute)*(m)*$/, function (pronoundCase, number, withWord, withM) {
873
892
  var waitTime = number * 1000 * 60;
874
893
  return browser.pause(waitTime);
875
894
  });
@@ -879,7 +898,7 @@ When(/^(I|we)* wait (\d*) minute(s)*$/, function (pronoundCase, number, withS) {
879
898
  * Example: When I wait max of 6 minutes
880
899
  *
881
900
  */
882
- When(/^(I|we)* wait max of (\d*) minute(s)*$/, function (pronoundCase, number, withS) {
901
+ When(/^(I|we)* wait max of (\d*)( minute)*(m)*$/, function (pronoundCase, number, withWord, withM) {
883
902
  var waitTime = number * 1000 * 60;
884
903
  return browser.waitForElementPresent('body', waitTime);
885
904
  });
@@ -889,7 +908,7 @@ When(/^(I|we)* wait max of (\d*) minute(s)*$/, function (pronoundCase, number, w
889
908
  * Example: When I wait until the page is loaded
890
909
  *
891
910
  */
892
- When(/^(I|we)* wait until the page( is)* loaded*$/, function (pronoundCase, withIs) {
911
+ When(/^(I|we)* wait until( the)* page( is)* loaded*$/, function (pronoundCase, theCase, withIs) {
893
912
  return browser.waitForElementPresent('body', 10000);
894
913
  });
895
914
  /**
@@ -897,7 +916,7 @@ When(/^(I|we)* wait until the page( is)* loaded*$/, function (pronoundCase, with
897
916
  * Example: Then the response status code should be 200
898
917
  *
899
918
  */
900
- Then(/^the response status code should be (\d+)$/, function (expectedStatusCode) {
919
+ Then(/^(the )*response status code should be (\d+)$/, function (theCase, expectedStatusCode) {
901
920
  return browser.url(function (currentURL) {
902
921
  axios.get(currentURL.value)
903
922
  .then(function (response) {
@@ -917,7 +936,7 @@ Then(/^the response status code should be (\d+)$/, function (expectedStatusCode)
917
936
  * Example: And the response status code should not be 404
918
937
  *
919
938
  */
920
- Then(/^the response status code should not be (\d+)$/, function ( expectedStatusCode) {
939
+ Then(/^(the )*response status code should not be (\d+)$/, function ( theCase, expectedStatusCode) {
921
940
  return browser.url(function (currentURL) {
922
941
  axios.get(currentURL.value)
923
942
  .then(function (response) {
@@ -964,7 +983,7 @@ Then(/^(I|we)* should not see text matching "([^"]*)?"$/, function (pronoundCase
964
983
  * //pattern of DD/MM/YYYY or DD-MM-YYYY
965
984
  *
966
985
  */
967
- Then(/^(I|we)* should see text matching "([^"]*)?" in the "([^"]*)?" element$/, function (pronoundCase, textPattern, element) {
986
+ Then(/^(I|we)* should see text matching "([^"]*)?" in( the)* "([^"]*)?" element$/, function (pronoundCase, textPattern, theCase, element) {
968
987
  return this.shouldSeePattern = function (browser) {
969
988
  browser.assert.textMatches(element, textPattern);
970
989
  };
@@ -976,7 +995,7 @@ Then(/^(I|we)* should see text matching "([^"]*)?" in the "([^"]*)?" element$/,
976
995
  * //pattern of DD/MM/YYYY or DD-MM-YYYY
977
996
  *
978
997
  */
979
- Then(/^(I|we)* should not see text matching "([^"]*)?" in the "([^"]*)?" element$/, function (pronoundCase, textPattern, element) {
998
+ Then(/^(I|we)* should not see text matching "([^"]*)?" in( the)* "([^"]*)?" element$/, function (pronoundCase, textPattern, element) {
980
999
  return this.shouldSeePattern = function (browser) {
981
1000
  browser.assert.not.textMatches(element, textPattern);
982
1001
  };
@@ -987,7 +1006,7 @@ Then(/^(I|we)* should not see text matching "([^"]*)?" in the "([^"]*)?" element
987
1006
  * Example: Then the url should match "/contact-us.html"
988
1007
  *
989
1008
  */
990
- Then(/^the url should match "([^"]*)?"$/, function (pattern) {
1009
+ Then(/^(the )*url should match "([^"]*)?"$/, function (theCase, pattern) {
991
1010
  return browser.assert.urlMatches(pattern);
992
1011
  });
993
1012
 
@@ -996,6 +1015,15 @@ Then(/^the url should match "([^"]*)?"$/, function (pattern) {
996
1015
  * Example: Then the url should not match "/contact-us.html"
997
1016
  *
998
1017
  */
999
- Then(/^the url should not match "([^"]*)?"$/, function (pattern) {
1018
+ Then(/^(the )*url should not match "([^"]*)?"$/, function (theCase, pattern) {
1000
1019
  return browser.assert.not.urlMatches(pattern);
1020
+ });
1021
+
1022
+ /**
1023
+ * Checks, Scrolls to the bottom of the current page
1024
+ * Example: When I scroll to the bottom
1025
+ *
1026
+ */
1027
+ When(/^(I|we)* scroll to( the)* bottom$/, async function(pronoundCase, theCase) {
1028
+ return browser.executeScript('window.scrollTo(0,document.body.scrollHeight);');
1001
1029
  });