webship-js 1.0.35 → 1.0.38

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.
@@ -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>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webship-js",
3
- "version": "1.0.35",
3
+ "version": "1.0.38",
4
4
  "description": "Webship JS automated functional testing.",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -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"
@@ -9,7 +9,13 @@ Feature: An example test to wait for a specific maximum number of seconds/minute
9
9
  And I wait 6 seconds
10
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
+ Given I am on the homepage
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.
13
19
  Given I am on the homepage
14
20
  When I go to "/test--when-i-wait-max-of-time.html"
15
21
  And I wait max of 6 seconds
@@ -68,7 +68,9 @@ When(/^(I|we)* go to "([^"]*)?"$/, function (pronoundCase, url) {
68
68
  *
69
69
  */
70
70
  Then(/^(I|we)* should see "([^"]*)?"$/, function (pronoundCase, expectedText) {
71
+ return this.shouldSee = function (browser) {
71
72
  browser.assert.textContains("html", expectedText);
73
+ };
72
74
  });
73
75
 
74
76
  /**
@@ -79,7 +81,9 @@ Then(/^(I|we)* should see "([^"]*)?"$/, function (pronoundCase, expectedText) {
79
81
  *
80
82
  */
81
83
  Then(/^(I|we)* should not see "([^"]*)?"$/, function (pronoundCase, expectedText) {
84
+ return this.shouldSee = function (browser) {
82
85
  browser.assert.not.textContains("html", expectedText);
86
+ };
83
87
  });
84
88
 
85
89
  /**
@@ -516,10 +520,49 @@ Then(/^(I|we)* should not be on the homepage$/, function (pronoundCase) {
516
520
  * Example: And I should be on "http://google.com"
517
521
  *
518
522
  */
523
+
519
524
  Then(/^(I|we)* should be on "([^"]*)?"$/, function (pronoundCase, url) {
520
525
  return browser.assert.urlContains(url);
521
526
  });
522
527
 
528
+ /**
529
+ * Verify, that the current link contains the specified URL.
530
+ * Example: Then the "Login" link should contain "/log-in"
531
+ *
532
+ */
533
+ Then(/^the "([^"]*)?" link should contain "([^"]*)?"$/, function (element, url) {
534
+ const elementField = browser.element.findByText(element, { exact: true });
535
+ return browser.assert.attributeContains(elementField, 'href', url);
536
+ });
537
+
538
+ /**
539
+ * Verify, that the current link contains the specified URL, found by its attributes.
540
+ * Example: Then the "#aboutUsid" link should contain "about" by attr
541
+ * Example: And the "aboutUs" link should contain "about" by its "class" attribute
542
+ * Example: And the ".contactUs" link should contain "/contact-" by attr
543
+ *
544
+ */
545
+ Then(/^the "([^"]*)?" link should contain "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (attrValue, url, itsCase, attr, attrCase) {
546
+
547
+ const hasASpace = attrValue.indexOf(' ');
548
+ var selector = '';
549
+
550
+ if((attrValue.startsWith('#') || attrValue.startsWith('.')) && hasASpace == -1){
551
+ selector = attrValue;
552
+ }
553
+ else if (!attr && hasASpace == -1){
554
+ selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "]," + '[value="' + attrValue + '"],[placeholder="' + attrValue + '"],' + '[title="' + attrValue + '"]';
555
+ }
556
+ else if (!attr && hasASpace > -1){
557
+ selector ='[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
558
+ }
559
+ else {
560
+ selector = '[' + attr + '="' + attrValue + '"]';
561
+ }
562
+
563
+ return browser.assert.attributeContains(selector, 'href', url);
564
+ });
565
+
523
566
  /**
524
567
  * Checks, that HTML response contains specific text
525
568
  * Example: Then the response should contain "Welcome visitor, How can I help you?"
@@ -846,9 +889,10 @@ Then(/^the checkbox "([^"]*)?" is not checked$/, function (checkbox) {
846
889
  * Wait a specific number of seconds.
847
890
  * Example: When I wait 1 second
848
891
  * Example: When I wait 5 seconds
892
+ * Example: When I wait 3s
849
893
  *
850
894
  */
851
- When(/^(I|we)* wait (\d*) second(s)*$/, function (pronoundCase, number, withS) {
895
+ When(/^(I|we)* wait (\d*)( second)*(s)*$/, function (pronoundCase, number, withWord, withS) {
852
896
  var waitTime = number * 1000;
853
897
  return browser.pause(waitTime);
854
898
  });
@@ -858,7 +902,7 @@ When(/^(I|we)* wait (\d*) second(s)*$/, function (pronoundCase, number, withS) {
858
902
  * Example: When I wait max of 6 seconds
859
903
  *
860
904
  */
861
- When(/^(I|we)* wait max of (\d*) second(s)*$/, function (pronoundCase, number, withS) {
905
+ When(/^(I|we)* wait max of (\d*)( second)*(s)*$/, function (pronoundCase, number, withWord, withS) {
862
906
  var waitTime = number * 1000;
863
907
  return browser.waitForElementPresent('body', waitTime);
864
908
  });
@@ -869,7 +913,7 @@ When(/^(I|we)* wait max of (\d*) second(s)*$/, function (pronoundCase, number, w
869
913
  * Example: When I wait 5 minutes
870
914
  *
871
915
  */
872
- When(/^(I|we)* wait (\d*) minute(s)*$/, function (pronoundCase, number, withS) {
916
+ When(/^(I|we)* wait (\d*)( minute)*(m)*$/, function (pronoundCase, number, withWord, withM) {
873
917
  var waitTime = number * 1000 * 60;
874
918
  return browser.pause(waitTime);
875
919
  });
@@ -879,7 +923,7 @@ When(/^(I|we)* wait (\d*) minute(s)*$/, function (pronoundCase, number, withS) {
879
923
  * Example: When I wait max of 6 minutes
880
924
  *
881
925
  */
882
- When(/^(I|we)* wait max of (\d*) minute(s)*$/, function (pronoundCase, number, withS) {
926
+ When(/^(I|we)* wait max of (\d*)( minute)*(m)*$/, function (pronoundCase, number, withWord, withM) {
883
927
  var waitTime = number * 1000 * 60;
884
928
  return browser.waitForElementPresent('body', waitTime);
885
929
  });