webship-js 1.0.10 → 1.0.12
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 +15 -8
- package/.github/workflows/github-actions.yml +13 -10
- package/.gitlab-ci.yml +1 -0
- package/.travis-ci.yml +0 -0
- package/README.md +1 -1
- package/assets/config_templates/circleci-linux-chrome.conf.js +100 -0
- package/assets/config_templates/github-linux-chrome.conf.js +111 -0
- package/{bitbucket-pipelines.yml → bitbucket-pipelines-test.yml} +0 -0
- package/examples/about-us.html +10 -0
- package/examples/contact-us.html +10 -0
- package/examples/index.html +26 -0
- package/examples/main.js +17 -0
- package/examples/test--when--i-fill-in.html +48 -0
- package/examples/test--when--i-follow-link.html +18 -0
- package/examples/test--when--i-press-button.html +27 -0
- package/examples/test--when--i-reload-page.html +27 -0
- package/examples/test--when--i-select-option-from-selectbox.html +35 -0
- package/lib/custom-commands/smartSelectOption.js +15 -0
- package/lib/get-element.js +65 -0
- package/nightwatch.conf.js +24 -259
- package/package.json +11 -4
- package/src/index.js +10 -0
- package/steplist.js +101 -64
- package/tests/features/test--given--i-am-on-homepage.feature +12 -0
- package/tests/features/test--when--i-fill-in.feature +36 -0
- package/tests/features/test--when--i-follow-link.feature +11 -0
- package/tests/features/test--when--i-move-forward-backward-one-page.feature +14 -0
- package/tests/features/test--when--i-press-button.feature +11 -0
- package/tests/features/test--when--i-reload-page.feature +14 -0
- package/tests/features/test--when--i-select-option-from-selectbox.feature +13 -0
- package/tests/reports/cucumber-report.html +0 -0
- package/tests/reports/cucumber-report.json +0 -0
- package/tests/step-definitions/webship.js +156 -10
- package/webpack.config.js +17 -0
- package/webship-init.js +75 -0
- package/tests/features/check-webshipco-site.feature +0 -8
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Feature: Example test for "I move forword one page",and "I move backword one page"
|
|
2
|
+
|
|
3
|
+
As a tester
|
|
4
|
+
I want to be able to test the navigate forward and backward in the browser history
|
|
5
|
+
So that I know it is working
|
|
6
|
+
|
|
7
|
+
Scenario: Check the "Navigate forward and backward" step definitions
|
|
8
|
+
Given I am on the homepage
|
|
9
|
+
When I go to "about-us.html"
|
|
10
|
+
When I move backward one page
|
|
11
|
+
When I move forward one page
|
|
12
|
+
Then I should see "About Us"
|
|
13
|
+
When I move backward one page
|
|
14
|
+
Then I should see "Welcome to the homepage of the Webship-js Examples"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Feature: Example test for "When I press button"
|
|
2
|
+
|
|
3
|
+
As a tester
|
|
4
|
+
I want to be able to test button press event
|
|
5
|
+
So that I know it is working
|
|
6
|
+
|
|
7
|
+
Scenario: Check the "When I press button" step definitions
|
|
8
|
+
Given I am on the homepage
|
|
9
|
+
When I go to "test--when--i-press-button.html"
|
|
10
|
+
When I press "Click Button"
|
|
11
|
+
Then I should see "Button Pressed Successfully"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Feature: Example test for "When I reload page"
|
|
2
|
+
|
|
3
|
+
As a tester
|
|
4
|
+
I want to be able to test page reload
|
|
5
|
+
So that I know it is working
|
|
6
|
+
|
|
7
|
+
Scenario: Check the "When I reload page" step definitions
|
|
8
|
+
Given I am on the homepage
|
|
9
|
+
When I go to "test--when--i-reload-page.html"
|
|
10
|
+
When I press "Click Button"
|
|
11
|
+
Then I should see "Button Pressed Successfully"
|
|
12
|
+
When I reload the page
|
|
13
|
+
Then I should not see "Button Pressed Successfully"
|
|
14
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Feature: Example test for "When I select option from select list"
|
|
2
|
+
|
|
3
|
+
As a tester
|
|
4
|
+
I want to be able to test select option from selectbox
|
|
5
|
+
|
|
6
|
+
Scenario: Check the "When I select 'option' from 'select list'" step definitions
|
|
7
|
+
Given I am on homepage
|
|
8
|
+
When I go to "test--when--i-select-option-from-selectbox.html"
|
|
9
|
+
When I select "saab" from "cars"
|
|
10
|
+
When I press "Check select"
|
|
11
|
+
Then I should see "Option ( Saab ) has been selected successfully"
|
|
12
|
+
|
|
13
|
+
|
|
File without changes
|
|
File without changes
|
|
@@ -2,27 +2,173 @@ const { Given } = require('@cucumber/cucumber');
|
|
|
2
2
|
const { When, Before } = require('@cucumber/cucumber');
|
|
3
3
|
const { Then } = require('@cucumber/cucumber');
|
|
4
4
|
|
|
5
|
+
const lib = require('../../lib/get-element.js');
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
8
|
+
* Opens homepage.
|
|
9
|
+
*
|
|
10
|
+
* Example: Given I am on homepage
|
|
11
|
+
* Example: Given I am on the homepage
|
|
7
12
|
*
|
|
8
|
-
*
|
|
9
|
-
|
|
13
|
+
* @Given /^I am on( the)* homepage$/
|
|
14
|
+
*/
|
|
15
|
+
Given(/^I am on( the)* homepage$/, function (url) {
|
|
16
|
+
return browser.url(browser.launch_url);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Opens specified page
|
|
21
|
+
* Example: Given I am on "about-us.html"
|
|
22
|
+
*
|
|
10
23
|
*/
|
|
11
|
-
Given(/^I
|
|
12
|
-
return browser.url(url);
|
|
24
|
+
Given(/^I am on "([^"]*)?"$/, function (url) {
|
|
25
|
+
return browser.url(browser.launch_url + url);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Opens homepage
|
|
30
|
+
* Example: When I go to the homepage
|
|
31
|
+
* Example: And I go to "/"
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
34
|
+
When(/^ I go to( the)* homepage$/, function () {
|
|
35
|
+
return browser.url(browser.launch_url);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Opens specified page
|
|
40
|
+
* Example: When I go to "contact-us.html"
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
When(/^I go to "([^"]*)?"$/, function (url) {
|
|
44
|
+
return browser.url(browser.launch_url + url);
|
|
13
45
|
});
|
|
14
46
|
|
|
15
47
|
/**
|
|
16
48
|
* Asserting a text in the page.
|
|
17
49
|
*
|
|
18
|
-
*
|
|
50
|
+
* Example:
|
|
19
51
|
* - Then I should see "Welcome"
|
|
20
52
|
* - Then I should not see "Access denied"
|
|
53
|
+
*
|
|
54
|
+
* @Then /^I should( not)* see "([^"]*)?"$/
|
|
21
55
|
*/
|
|
22
|
-
Then(/^I should( not)* see "([^"]*)?"$/, function(negativeCase, expectedText) {
|
|
56
|
+
Then(/^I should( not)* see "([^"]*)?"$/, function (negativeCase, expectedText) {
|
|
23
57
|
if (negativeCase) {
|
|
24
|
-
return browser.assert.not.textContains('
|
|
58
|
+
return browser.assert.not.textContains('html', expectedText);
|
|
25
59
|
}
|
|
60
|
+
|
|
61
|
+
return browser.assert.textContains('html', expectedText);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Moves forward one page in history
|
|
66
|
+
* Example: And I move forward one page
|
|
67
|
+
*
|
|
68
|
+
* @When /^I move forward one page$/
|
|
69
|
+
*/
|
|
70
|
+
When(/^I move forward one page$/, function () {
|
|
71
|
+
return browser.forward();
|
|
72
|
+
});
|
|
26
73
|
|
|
27
|
-
|
|
28
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Moves backward one page in history
|
|
76
|
+
* Example: When I move backward one page
|
|
77
|
+
*
|
|
78
|
+
* @When /^I move backward one page$/
|
|
79
|
+
*/
|
|
80
|
+
When(/^I move backward one page$/, function () {
|
|
81
|
+
return browser.back();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Presses button with specified id|name|title|alt|value
|
|
86
|
+
* Example: When I press "Log In"
|
|
87
|
+
* Example: And I press "Log In"
|
|
88
|
+
*
|
|
89
|
+
* @When /^I press "([^"]*)?"$/
|
|
90
|
+
*/
|
|
91
|
+
When(/^I press "([^"]*)?"$/, function (elementValue) {
|
|
92
|
+
return browser.click("[value='" + elementValue + "']");
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Clicks link with specified id|title|alt|text
|
|
97
|
+
* Example: When I follow "Log In"
|
|
98
|
+
* Example: And I follow "Log In"
|
|
99
|
+
*
|
|
100
|
+
* @When /^I follow "([^"]*)?"$/
|
|
101
|
+
*/
|
|
102
|
+
When(/^I follow "([^"]*)?"$/, function (elementValue) {
|
|
103
|
+
return browser.click("link text", elementValue);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Reloads current page
|
|
108
|
+
* Example: When I reload the page
|
|
109
|
+
* Example: And I reload the page
|
|
110
|
+
*
|
|
111
|
+
*/
|
|
112
|
+
When(/^I reload( the)* page$/, function (url) {
|
|
113
|
+
return browser.refresh(browser.getCurrentUrl());
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Fills in form field with specified id|name|label|value
|
|
118
|
+
* Example: When I fill in "username" with "webshipco"
|
|
119
|
+
*
|
|
120
|
+
* @When /^I fill in "([^"]*)?" with "([^"]*)?"$/
|
|
121
|
+
*/
|
|
122
|
+
When(/^I fill in "([^"]*)?" with "([^"]*)?"$/, function (field, value) {
|
|
123
|
+
lib.fillInputWithValue(field, value);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Fills in form field with specified id|name|label|value
|
|
128
|
+
* Example: When I fill in "username" with:
|
|
129
|
+
*
|
|
130
|
+
* @When /^I fill in "([^"]*)?" with:$/
|
|
131
|
+
*/
|
|
132
|
+
When(/^I fill in "([^"]*)?" with:$/, function (field) {
|
|
133
|
+
lib.fillInputWithValue(field, '');
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Fills in form field with specified id|name|label|value
|
|
138
|
+
* Example: And I fill in "webshipco" for "username"
|
|
139
|
+
*
|
|
140
|
+
* @When /^I fill in "([^"]*)?" for "([^"]*)?"$/
|
|
141
|
+
*/
|
|
142
|
+
When(/^I fill in "([^"]*)?" for "([^"]*)?"$/, function (value, field) {
|
|
143
|
+
lib.fillInputWithValue(field, value);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Fills in form fields with provided table
|
|
148
|
+
* Example: When I fill in the following:
|
|
149
|
+
* | username | webshipco |
|
|
150
|
+
* | password | 1234 |
|
|
151
|
+
* Example: And I fill in the following"
|
|
152
|
+
* | username | webshipco |
|
|
153
|
+
* | password | 1234 |
|
|
154
|
+
*
|
|
155
|
+
* @When /^I fill in the following:$/
|
|
156
|
+
*/
|
|
157
|
+
When(/^I fill in the following:$/, function (table) {
|
|
158
|
+
|
|
159
|
+
lib.fillInputWithValue(table.rawTable[0][0], table.rawTable[0][1]);
|
|
160
|
+
table.rows().forEach(row => {
|
|
161
|
+
lib.fillInputWithValue(row[0], row[1]);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Selects option in select field with specified id|name|label|value
|
|
167
|
+
* Example: When I select "saab" from "Cars"
|
|
168
|
+
* Example: And I select "saab" from "Cars"
|
|
169
|
+
*
|
|
170
|
+
* @When /^I select "([^"]*)?" from "([^"]*)?"$/
|
|
171
|
+
*/
|
|
172
|
+
When(/^I select "([^"]*)?" from "([^"]*)?"$/, function (option, selectBox) {
|
|
173
|
+
browser.smartSelectOption(option, selectBox);
|
|
174
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
entry: './src/index.js',
|
|
5
|
+
mode: 'development',
|
|
6
|
+
output: {
|
|
7
|
+
filename: 'main.js',
|
|
8
|
+
path: path.resolve(__dirname, 'examples'),
|
|
9
|
+
},
|
|
10
|
+
devServer: {
|
|
11
|
+
static: {
|
|
12
|
+
directory: path.join(__dirname, 'examples'),
|
|
13
|
+
},
|
|
14
|
+
compress: true,
|
|
15
|
+
port: 8080,
|
|
16
|
+
},
|
|
17
|
+
};
|
package/webship-init.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
var insidProject = false;
|
|
6
|
+
var basePath = '';
|
|
7
|
+
var projectPath = '';
|
|
8
|
+
|
|
9
|
+
const currentPath = process.argv[1].split("node_modules");
|
|
10
|
+
basePath = currentPath[0].substring(0, currentPath[0].lastIndexOf("/")) + '/';
|
|
11
|
+
|
|
12
|
+
if(currentPath.length > 1){
|
|
13
|
+
projectPath = basePath + "node_modules/webship-js/";
|
|
14
|
+
}
|
|
15
|
+
else{
|
|
16
|
+
projectPath = basePath;
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* -----------------------------------------------------
|
|
22
|
+
* Parse arguments
|
|
23
|
+
* -----------------------------------------------------
|
|
24
|
+
*/
|
|
25
|
+
const { ArgumentParser } = require('argparse');
|
|
26
|
+
const { version } = require('./package.json');
|
|
27
|
+
|
|
28
|
+
const parser = new ArgumentParser({
|
|
29
|
+
description: 'Argparse example'
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
parser.add_argument('-ci', '--continuous_integration',
|
|
33
|
+
{
|
|
34
|
+
help: 'Add your CI services (circleci, github, gitlab, bitbucket), By default: -ci circleci',
|
|
35
|
+
default: 'circleci',
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
parser.add_argument('-b', '--browser',
|
|
39
|
+
{
|
|
40
|
+
help: 'Add your Browser (chrome, firefox), By default: -b chrome',
|
|
41
|
+
default: 'chrome',
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
parser.add_argument('-os', '--operating_system',
|
|
45
|
+
{
|
|
46
|
+
help: 'Add your Operating System (linux, mac, windows), By default: -os linux',
|
|
47
|
+
default: 'linux',
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
var argsParse = parser.parse_args();
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* -----------------------------------------------------
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Generate the appropriate nightwatch.conf.js
|
|
58
|
+
*
|
|
59
|
+
* Generate nightwatch testing configs according to the used CI
|
|
60
|
+
* service, operating system, and browser.
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
fs.unlink(projectPath + 'nightwatch.conf.js', (err) => {
|
|
64
|
+
if (err) {
|
|
65
|
+
throw err;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const confTemplate = projectPath + 'assets/config_templates/' + argsParse.continuous_integration + '-' + argsParse.operating_system + '-' + argsParse.browser + '.conf.js';
|
|
70
|
+
|
|
71
|
+
fs.copyFile(confTemplate, projectPath + 'nightwatch.conf.js', (err) => {
|
|
72
|
+
if (err) {
|
|
73
|
+
throw err;
|
|
74
|
+
}
|
|
75
|
+
});
|