webship-js 1.0.34 → 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.
@@ -14,7 +14,7 @@ jobs:
14
14
  - name: Install/Update Google Chrome browser
15
15
  run: |
16
16
  sudo apt install libu2f-udev
17
- sudo apt-get install libappindicator1 fonts-liberation libgbm1 libgtk-3-0 xdg-utils
17
+ sudo apt-get install libappindicator3-1 fonts-liberation libgbm1 libgtk-3-0 xdg-utils
18
18
  export CHROME_BIN=/usr/bin/google-chrome
19
19
  wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
20
20
  sudo dpkg -i google-chrome-stable_current_amd64.deb
@@ -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>
@@ -11,11 +11,28 @@
11
11
  </style>
12
12
  <script>
13
13
  function onClick() {
14
- const myfile = document.getElementById("fileUpload");
14
+ const imageUpload = document.getElementById("fileUpload");
15
15
  const element = document.getElementById("result");
16
- const img = document.getElementById("img");
17
- const filePathArr = myfile.value.split('\\');
16
+ const filePathArr = imageUpload.value.split('\\');
18
17
  element.innerText = filePathArr[filePathArr.length - 1];
18
+
19
+ const file = imageUpload.files[0];
20
+
21
+ // Create a FileReader object
22
+ const reader = new FileReader();
23
+
24
+ // Set up the reader's onload event handler
25
+ reader.onload = function(e) {
26
+ // Get the image data URL
27
+ const imageDataUrl = e.target.result;
28
+
29
+ // Display the uploaded image
30
+ const imagePreview = document.getElementById('imagePreview');
31
+ imagePreview.src = imageDataUrl;
32
+ };
33
+
34
+ // Read the selected file as Data URL
35
+ reader.readAsDataURL(file);
19
36
 
20
37
  }
21
38
  </script>
@@ -24,6 +41,7 @@
24
41
  <body>
25
42
  <label for="myfile">Select a file:</label>
26
43
  <input type="file" id="fileUpload" name="fileUpload"><br><br>
44
+ <img id="imagePreview" src="#" width="150" height="150" />
27
45
  <div id="result" class="style"></div><br />
28
46
  <input type="submit" value="Submit" onclick="onClick()">
29
47
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webship-js",
3
- "version": "1.0.34",
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"
@@ -1,10 +1,11 @@
1
- Feature: An example of checking the attachment of a file to a field and uploading it
1
+ Feature: An example of checking the attachment of a file to a field
2
2
 
3
3
  As a tester,
4
4
  I want to be able to attach a file (e.g., images) to a field
5
5
 
6
- # Scenario: Checking the attachment of an image to a field and uploading it
7
- # Given I am on "/test--when--i-attach-file-to-feild.html"
8
- # When I attach the file "webshipco.png" to "#fileUpload"
9
- # When I press "Submit" by attr
10
- # Then I should see "webshipco.png"
6
+ Scenario: Checking the attachment of an image to a field
7
+ Given I am on "/test--when--i-attach-file-to-feild.html"
8
+ When I attach the file "webshipco.png" to "#fileUpload"
9
+ And I press "Submit" by attr
10
+ And I wait 2 second
11
+ Then I should see "webshipco.png"
@@ -3,13 +3,17 @@ Feature: An example of pressing a button using its attributes.
3
3
  As a tester,
4
4
  I want to be able to press a button using its attributes.
5
5
 
6
- Scenario: Verify that you can click a button using its ID attribute.
6
+ Scenario: Verify that you can click a button by specifying its ID with the '#' sign.
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"
10
+
11
+ Scenario: Verify that you can click a button by specifying the 'ID' attribute without the '#' sign.
7
12
  Given I am on "/test--when--i-press-button.html"
8
13
  When I press "btn-pressid" by "id" attr
9
14
  Then I should see "Button Pressed Successfully"
10
15
 
11
- Scenario: Verify that you can click a button using its default name attribute.
16
+ Scenario: Verify that you can click a button without specifying any attributes or signs, using only the value of one of its attributes.
12
17
  Given I am on "/test--when--i-press-button.html"
13
18
  When I press "btn-pressname" by attr
14
19
  Then I should see "Button Pressed Successfully"
15
-
@@ -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
  /**
@@ -122,9 +126,12 @@ When(/^(I|we)* press "([^"]*)?"$/, function (pronoundCase, element) {
122
126
  When(/^(I|we)* press "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, attrValue, itsCase, attr, attrCase) {
123
127
 
124
128
  const hasASpace = attrValue.indexOf(' ');
125
-
126
129
  var selector = '';
127
- if (!attr && hasASpace == -1){
130
+
131
+ if((attrValue.startsWith('#') || attrValue.startsWith('.')) && hasASpace == -1){
132
+ selector = attrValue;
133
+ }
134
+ else if (!attr && hasASpace == -1){
128
135
  selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "]," + '[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
129
136
  }
130
137
  else if (!attr && hasASpace > -1){
@@ -134,7 +141,7 @@ When(/^(I|we)* press "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, func
134
141
  selector = '[' + attr + '="' + attrValue + '"]';
135
142
  }
136
143
 
137
- browser.click(selector);
144
+ return browser.click(selector);
138
145
  });
139
146
 
140
147
  /**
@@ -513,10 +520,49 @@ Then(/^(I|we)* should not be on the homepage$/, function (pronoundCase) {
513
520
  * Example: And I should be on "http://google.com"
514
521
  *
515
522
  */
523
+
516
524
  Then(/^(I|we)* should be on "([^"]*)?"$/, function (pronoundCase, url) {
517
525
  return browser.assert.urlContains(url);
518
526
  });
519
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
+
520
566
  /**
521
567
  * Checks, that HTML response contains specific text
522
568
  * Example: Then the response should contain "Welcome visitor, How can I help you?"
@@ -730,11 +776,14 @@ Then(/^the "([^"]*)?" element should not contain "([^"]*)?"$/, function (selecto
730
776
 
731
777
  /**
732
778
  * Attaches file to field
733
- * Example: When I attach the file "profileIcon.jpg" to "profileIconUpload"
779
+ * Example: When I attach the file "profileIcon.jpg" to "#profileIconUpload"
734
780
  *
735
781
  */
736
782
  When(/^(I|we)* attach the file "([^"]*)?" to "([^"]*)?"$/, function (pronoundCase, fileUrl, element) {
737
-
783
+ var dirname = __dirname + '';
784
+ dirname = dirname.substring(0, dirname.lastIndexOf("/"));
785
+
786
+ return browser.setValue(element, dirname + '/assets/' + fileUrl);
738
787
  });
739
788
 
740
789
  /**
@@ -840,9 +889,10 @@ Then(/^the checkbox "([^"]*)?" is not checked$/, function (checkbox) {
840
889
  * Wait a specific number of seconds.
841
890
  * Example: When I wait 1 second
842
891
  * Example: When I wait 5 seconds
892
+ * Example: When I wait 3s
843
893
  *
844
894
  */
845
- When(/^(I|we)* wait (\d*) second(s)*$/, function (pronoundCase, number, withS) {
895
+ When(/^(I|we)* wait (\d*)( second)*(s)*$/, function (pronoundCase, number, withWord, withS) {
846
896
  var waitTime = number * 1000;
847
897
  return browser.pause(waitTime);
848
898
  });
@@ -852,7 +902,7 @@ When(/^(I|we)* wait (\d*) second(s)*$/, function (pronoundCase, number, withS) {
852
902
  * Example: When I wait max of 6 seconds
853
903
  *
854
904
  */
855
- 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) {
856
906
  var waitTime = number * 1000;
857
907
  return browser.waitForElementPresent('body', waitTime);
858
908
  });
@@ -863,7 +913,7 @@ When(/^(I|we)* wait max of (\d*) second(s)*$/, function (pronoundCase, number, w
863
913
  * Example: When I wait 5 minutes
864
914
  *
865
915
  */
866
- When(/^(I|we)* wait (\d*) minute(s)*$/, function (pronoundCase, number, withS) {
916
+ When(/^(I|we)* wait (\d*)( minute)*(m)*$/, function (pronoundCase, number, withWord, withM) {
867
917
  var waitTime = number * 1000 * 60;
868
918
  return browser.pause(waitTime);
869
919
  });
@@ -873,7 +923,7 @@ When(/^(I|we)* wait (\d*) minute(s)*$/, function (pronoundCase, number, withS) {
873
923
  * Example: When I wait max of 6 minutes
874
924
  *
875
925
  */
876
- 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) {
877
927
  var waitTime = number * 1000 * 60;
878
928
  return browser.waitForElementPresent('body', waitTime);
879
929
  });