webship-js 1.0.18 → 1.0.20

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/README.md CHANGED
@@ -12,21 +12,19 @@ Webship JS has a ready step definitions for automated functional testing.
12
12
 
13
13
 
14
14
  ### Webship-js Documentations
15
- All you need to know about [webship-js Docs](https://webship.co/documentation/webship-js).
15
+ All you need to know about [webship-js Docs](https://webship.co/docs/webship-js/1.0.x).
16
16
 
17
17
 
18
- ## How to configure your project to test using webship-js steps
19
-
20
- ### Install node js and yarn
21
-
22
- ### Install Latest Chrome Driver
23
-
24
- ### Run selenium standalone server
25
-
26
18
  ## Install webship-js using Yarn
27
19
 
28
20
  ```
29
21
  yarn add webship-js
22
+ ```
23
+
24
+ ## Install files required by the webship-js tool
25
+
26
+ ```
27
+ bash <(wget -O - https://raw.githubusercontent.com/webship/wbash/v1/webship-js/v1/template.sh)
30
28
  ```
31
29
 
32
30
  ## Automated Functional Acceptance Testing
@@ -17,12 +17,14 @@
17
17
  <li><a href="about-us.html">About Us</a></li>
18
18
  <li><a href="test--when--i-press-button.html">When I press "Button"</a></li>
19
19
  <li><a href="test--when--i-reload-page.html">When I go reload page</a></li>
20
- <li><a href="test--when--i-follow-link.html">When I go follow "link"</a></li>
20
+ <li><a href="test--when--i-click-link.html">When I click "link"</a></li>
21
21
  <li><a href="test--when--i-fill-in.html">When I fill in input text with value</a></li>
22
22
  <li><a href="test--when--i-select-option-from-selectbox.html">When I select option from select box</a></li>
23
23
  <li><a href="test--then--i-should--not--see-text-in-element.html">Then I sould (not) see test in element</a></li>
24
24
  <li><a href="test--then--the-element-should_not-contain-cssproperty.html">Then the element should (not) contain css property</a></li>
25
25
  <li><a href="test--then--the-checkbox-checked.html">Then the checkbox (is/should be) (not) checked</a></li>
26
+ <li><a href="test--when-i-wait-specific-time.html">When I Wait a specific Time</a></li>
27
+ <li><a href="test--when-i-wait-max-of-time.html">When I Wait a Maximum of Time</a></li>
26
28
  </ul>
27
29
  <script src="main.js"></script>
28
30
  </body>
@@ -2,7 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
  <meta charset='utf-8'>
5
- <title>Follow Link</title>
5
+ <title>Click Link</title>
6
6
  <style>
7
7
  .style{
8
8
  font-size: 26px;
@@ -10,9 +10,9 @@
10
10
  </style>
11
11
  </head>
12
12
  <body>
13
- <h1>Follow Link</h1>
13
+ <h1>Click Link</h1>
14
14
  <div id="result" class="style">
15
- Please click <a id="aboutUs" class="aboutUs" href="about-us.html">About us link</a> for more information.
15
+ Please click <a id="aboutUsid" class="aboutUs" href="about-us.html">About us link</a> for more information.
16
16
  </div>
17
17
  </body>
18
18
  </html>
@@ -0,0 +1,39 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <meta charset='utf-8'>
6
+ <title>I wait time</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: 50px;
17
+ }
18
+ </style>
19
+
20
+ </head>
21
+
22
+ <body>
23
+ <h1>Waiting Max number of Time</h1>
24
+
25
+ <div class="container">
26
+ <b><div id="result" class="style">Waiting . . .</div></b>
27
+
28
+ </body>
29
+
30
+ <script>
31
+ const element = document.getElementById("result");
32
+ const timeWate = 3;
33
+
34
+ setTimeout(() => {
35
+ element.innerText = 'Welcome with waiting until page load';
36
+ }, timeWate * 1000);
37
+
38
+ </script>
39
+ </html>
@@ -0,0 +1,39 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <meta charset='utf-8'>
6
+ <title>I wait time</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: 50px;
17
+ }
18
+ </style>
19
+
20
+ </head>
21
+
22
+ <body>
23
+ <h1>Waiting a Specific number of Time</h1>
24
+
25
+ <div class="container">
26
+ <b><div id="result" class="style">Waiting . . .</div></b>
27
+
28
+ </body>
29
+
30
+ <script>
31
+ const element = document.getElementById("result");
32
+ const timeWate = 3;
33
+
34
+ setTimeout(() => {
35
+ element.innerText = 'Welcome with waiting full time';
36
+ }, timeWate * 1000);
37
+
38
+ </script>
39
+ </html>
@@ -0,0 +1,23 @@
1
+
2
+ module.exports.command = function (item) {
3
+
4
+ browser.element('css selector', item, function (result) {
5
+ if (result.status === 0) {
6
+ return browser.click(item);
7
+ } else {
8
+ browser.element('css selector', '#' + item, function (result) {
9
+ if (result.status === 0) {
10
+ return browser.click('#' + item);
11
+ } else {
12
+ browser.element('css selector', '.' + item, function (result) {
13
+ if (result.status === 0) {
14
+ return browser.click('.' + item);
15
+ } else {
16
+ return browser.click("link text", item);
17
+ }
18
+ });
19
+ }
20
+ });
21
+ }
22
+ });
23
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webship-js",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "Webship JS automated functional testing.",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -0,0 +1,17 @@
1
+ Feature: Example test for "When I click 'link'"
2
+
3
+ As a tester
4
+ I want to be able to test when a link is clicked,
5
+ it will go to the link path page
6
+
7
+ Scenario: Check the "When I click link" by link text step definitions
8
+ Given I am on "test--when--i-click-link.html"
9
+ When I click "About us link"
10
+ And I wait max of 2 seconds
11
+ Then I should see "About Us"
12
+
13
+ Scenario: Check the "When I click link" by link css class step definitions
14
+ Given I am on "test--when--i-click-link.html"
15
+ When I click "aboutUs"
16
+ And I wait max of 2 seconds
17
+ Then I should see "About Us"
@@ -0,0 +1,15 @@
1
+ Feature: Example test for Wait a Specific/Max number of seconds/minutes for page load
2
+ As a tester
3
+ I want to make sure that I can wait for a page to load, an element to visible
4
+
5
+ Scenario: Check page content to load
6
+ Given I am on the homepage
7
+ When I go to "test--when-i-wait-specific-time.html"
8
+ And I wait 6 seconds
9
+ Then I should see "Welcome with waiting full time"
10
+
11
+ Scenario: Check page content to load
12
+ Given I am on the homepage
13
+ When I go to "test--when-i-wait-max-of-time.html"
14
+ And I wait max of 6 seconds
15
+ Then I should see "Welcome with waiting until page load"
@@ -82,7 +82,7 @@ When(/^I move backward one page$/, function () {
82
82
  });
83
83
 
84
84
  /**
85
- * Presses button with specified id|class|name|title|value
85
+ * Presses button with specified id|class|name|value
86
86
  * Example: When I press "Log In"
87
87
  * Example: And I press "Log In"
88
88
  *
@@ -94,14 +94,14 @@ When(/^I press "([^"]*)?"$/, function (elementValue) {
94
94
  });
95
95
 
96
96
  /**
97
- * Clicks link with specified id|class|name|title|text
98
- * Example: When I follow "Contact Us"
99
- * Example: And I follow "Log In"
97
+ * Clicks link with specified id|class|name|text
98
+ * Example: When I click "Contact Us"
99
+ * Example: And I click "aboutUs"
100
100
  *
101
- * @When /^I follow "([^"]*)?"$/
101
+ * @When /^I click "([^"]*)?"$/
102
102
  */
103
- When(/^I follow "([^"]*)?"$/, function (item) {
104
- browser.smartLinkFollow(item);
103
+ When(/^I click "([^"]*)?"$/, function (item) {
104
+ browser.smartClickLink(item);
105
105
  });
106
106
 
107
107
  /**
@@ -344,4 +344,40 @@ Then(/^the checkbox "([^"]*)?" should( not)* be checked$/, function (checkbox, n
344
344
  */
345
345
  Then(/^the checkbox "([^"]*)?" is( not)* checked$/, function (checkbox, negativeCase) {
346
346
  return browser.assert.smartCheckboxChecked(checkbox, negativeCase);
347
+ });
348
+
349
+ /**
350
+ * Wait a specific number of seconds, or a max number of seconds
351
+ until the element present.
352
+ * Example: When I wait 1 second
353
+ * Example: When I wait 5 seconds
354
+ * Example: When I wait max of 6 seconds
355
+ *
356
+ * @When /^I wait( max of)* "([^"]*)?" second(s)*$/
357
+ *
358
+ */
359
+ When(/^I wait( max of)* (\d*) second(s)*$/, function (maxof, number, withS) {
360
+ var waitTime = number * 1000;
361
+ if (maxof) {
362
+ return browser.waitForElementPresent('body', waitTime);
363
+ }
364
+ return browser.pause(waitTime);
365
+ });
366
+
367
+ /**
368
+ * Wait a specific number of minutes, or a max number of minutes
369
+ until the element present.
370
+ * Example: When I wait 1 minute
371
+ * Example: When I wait 5 minutes
372
+ * Example: When I wait max of 6 minutes
373
+ *
374
+ * @When /^I wait( max of)* "([^"]*)?" second(s)*$/
375
+ *
376
+ */
377
+ When(/^I wait( max of)* (\d*) minute(s)*$/, function (maxof, number, withS) {
378
+ var waitTime = number * 60 * 1000;
379
+ if (maxof) {
380
+ return browser.waitForElementPresent('body', waitTime);
381
+ }
382
+ return browser.pause(waitTime);
347
383
  });
@@ -1,17 +0,0 @@
1
-
2
- module.exports.command = function (item) {
3
-
4
- browser.element('css selector', item, function (result) {
5
- if (result.status === 0) {
6
- return browser.click("link text", result.value);
7
- } else {
8
- browser.element('css selector', '#' + item, function (result) {
9
- if (result.status === 0) {
10
- return browser.click("link text", result.value);
11
- } else {
12
- return browser.click("link text", item);
13
- }
14
- });
15
- }
16
- });
17
- }
@@ -1,13 +0,0 @@
1
- Feature: Example test for "When I follow 'link'"
2
-
3
- As a tester
4
- I want to be able to test when a link is clicked,
5
- it will go to the link path page
6
-
7
- Scenario: Check the "When I follow link" step definitions
8
- Given I am on "test--when--i-follow-link.html"
9
- When I follow "About us link"
10
- Then I should see "About Us"
11
- When I move backward one page
12
- And I follow "aboutUs"
13
- Then I should see "About Us"