webship-js 1.0.16 → 1.0.18
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 +4 -57
- package/examples/index.html +2 -1
- package/examples/test--then--the-checkbox-checked.html +68 -0
- package/examples/test--when--i-attach-file-to-feild.html +32 -0
- package/examples/test--when--i-follow-link.html +1 -1
- package/generate-reports.js +22 -0
- package/lib/custom-assertions/smartCheckboxChecked.js +54 -0
- package/lib/custom-commands/smartLinkFollow.js +17 -0
- package/lib/custom-commands/smartUploadFile.js +38 -0
- package/package.json +3 -2
- package/tests/assets/webshipco.png +0 -0
- package/tests/features/test--then--the-checkbox-checked.feature +16 -0
- package/tests/features/test--then--the-field-should-contain-value.feature +12 -0
- package/tests/features/test--when--i-attach-file-to-feild.feature +10 -0
- package/tests/features/test--when--i-follow-link.feature +9 -7
- package/tests/step-definitions/webship.js +100 -42
- package/webship-init.js +14 -14
- package/lib/custom-commands/smartLinkClick.js +0 -12
package/README.md
CHANGED
|
@@ -12,78 +12,25 @@ 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://
|
|
15
|
+
All you need to know about [webship-js Docs](https://webship.co/documentation/webship-js).
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
## How to configure your project to test using webship-js steps
|
|
19
19
|
|
|
20
20
|
### Install node js and yarn
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
sudo apt install nodejs
|
|
24
|
-
sudo npm install yarn
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### Install Java
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
sudo apt install java
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### Download Latest Chrome Driver
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
CHROME_DRIVER_VERSION=$(wget -qO- chromedriver.storage.googleapis.com/LATEST_RELEASE);
|
|
37
|
-
echo $CHROME_DRIVER_VERSION;
|
|
38
|
-
wget http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip
|
|
39
|
-
unzip chromedriver_linux64.zip
|
|
40
|
-
chmod +x chromedriver
|
|
41
|
-
mkdir -p $HOME/.composer/vendor/bin
|
|
42
|
-
mv -f chromedriver $HOME/.composer/vendor/bin/
|
|
43
|
-
rm chromedriver_linux64.zip
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### Install/Update Chrome Driver
|
|
47
|
-
|
|
48
|
-
```
|
|
49
|
-
export CHROME_BIN=/usr/bin/google-chrome
|
|
50
|
-
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
|
|
51
|
-
sudo apt-get clean
|
|
52
|
-
sudo apt-get update
|
|
53
|
-
sudo apt-get install dpkg
|
|
54
|
-
sudo dpkg -i google-chrome-stable_current_amd64.deb
|
|
55
|
-
rm google-chrome-stable_current_amd64.deb
|
|
56
|
-
google-chrome --version
|
|
57
|
-
```
|
|
22
|
+
### Install Latest Chrome Driver
|
|
58
23
|
|
|
59
24
|
### Run selenium standalone server
|
|
60
25
|
|
|
61
|
-
|
|
62
|
-
cd ~
|
|
63
|
-
wget https://github.com/SeleniumHQ/selenium/releases/download/selenium-3.141.59/selenium-server-standalone-3.141.59.jar
|
|
64
|
-
java -jar selenium-server-standalone-3.141.59.jar -port 4444
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## How to install using Yarn
|
|
26
|
+
## Install webship-js using Yarn
|
|
68
27
|
|
|
69
28
|
```
|
|
70
29
|
yarn add webship-js
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## How to install using NPM
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
npm install webship-js
|
|
77
30
|
```
|
|
78
31
|
|
|
79
32
|
## Automated Functional Acceptance Testing
|
|
80
33
|
|
|
81
34
|
```
|
|
82
35
|
yarn test
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
Or
|
|
86
|
-
|
|
87
|
-
```
|
|
88
|
-
npm test
|
|
89
|
-
```
|
|
36
|
+
```
|
package/examples/index.html
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<h3>Welcome to the homepage of the Webship-js Examples</h3>
|
|
15
15
|
<ul>
|
|
16
16
|
<li><a href="/">Given I go to homepage</a></li>
|
|
17
|
-
<li><a href="about-us.html">
|
|
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
20
|
<li><a href="test--when--i-follow-link.html">When I go follow "link"</a></li>
|
|
@@ -22,6 +22,7 @@
|
|
|
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
|
+
<li><a href="test--then--the-checkbox-checked.html">Then the checkbox (is/should be) (not) checked</a></li>
|
|
25
26
|
</ul>
|
|
26
27
|
<script src="main.js"></script>
|
|
27
28
|
</body>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset='utf-8'>
|
|
6
|
+
<title>Item should be checked</title>
|
|
7
|
+
<style>
|
|
8
|
+
.container,
|
|
9
|
+
.container input,
|
|
10
|
+
.container button {
|
|
11
|
+
font-size: 22px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.style {
|
|
15
|
+
width: 400px;
|
|
16
|
+
height: 50px;
|
|
17
|
+
font-size: 22px;
|
|
18
|
+
line-height: 50px;
|
|
19
|
+
text-align: center;
|
|
20
|
+
}
|
|
21
|
+
</style>
|
|
22
|
+
|
|
23
|
+
<script>
|
|
24
|
+
function onClick() {
|
|
25
|
+
const element = document.getElementById("result");
|
|
26
|
+
const PrivacyPolicy = document.getElementById("PrivacyPolicy");
|
|
27
|
+
if (PrivacyPolicy.checked) {
|
|
28
|
+
element.innerText = "Registration Done Successfully";
|
|
29
|
+
} else {
|
|
30
|
+
element.innerText = "Please check Agree to Privacy Policy";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
</head>
|
|
37
|
+
|
|
38
|
+
<body>
|
|
39
|
+
<h1>Registration</h1>
|
|
40
|
+
|
|
41
|
+
<div class="container">
|
|
42
|
+
<p>
|
|
43
|
+
<label for="email">Email</label><br/>
|
|
44
|
+
<input type="text" placeholder="Enter Email" name="email" id="email" required>
|
|
45
|
+
</p>
|
|
46
|
+
<p>
|
|
47
|
+
<label for="psw">Password</label><br/>
|
|
48
|
+
<input type="password" placeholder="Enter Password" name="psw" id="psw" required>
|
|
49
|
+
</p>
|
|
50
|
+
<p>
|
|
51
|
+
<label for="psw-repeat">Repeat Password</label><br/>
|
|
52
|
+
<input type="password" placeholder="Repeat Password" name="psw-repeat" id="psw-repeat" required>
|
|
53
|
+
</p>
|
|
54
|
+
<hr>
|
|
55
|
+
|
|
56
|
+
<p><input type="checkbox" value="lsRememberMe" id="rememberMe"> <label for="rememberMe">Remember me</label></p>
|
|
57
|
+
<p><input type="checkbox" value="lsPrivacyPolicy" id="PrivacyPolicy"> <label for="PrivacyPolicy">I Agree to Privacy Policy</label></p>
|
|
58
|
+
|
|
59
|
+
<p><input id="registerbtn" class="registerbtn" name="registerbtn" type="button" value="Register"
|
|
60
|
+
onclick="onClick()"></p>
|
|
61
|
+
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<div id="result" class="style"></div><br />
|
|
65
|
+
|
|
66
|
+
</body>
|
|
67
|
+
|
|
68
|
+
</html>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset='utf-8'>
|
|
6
|
+
<title>Press Button</title>
|
|
7
|
+
<style>
|
|
8
|
+
.style {
|
|
9
|
+
font-size: 26px;
|
|
10
|
+
}
|
|
11
|
+
</style>
|
|
12
|
+
<script>
|
|
13
|
+
function onClick() {
|
|
14
|
+
const myfile = document.getElementById("fileUpload");
|
|
15
|
+
const element = document.getElementById("result");
|
|
16
|
+
const img = document.getElementById("img");
|
|
17
|
+
const filePathArr = myfile.value.split('\\');
|
|
18
|
+
element.innerText = filePathArr[filePathArr.length - 1];
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
</script>
|
|
22
|
+
</head>
|
|
23
|
+
|
|
24
|
+
<body>
|
|
25
|
+
<label for="myfile">Select a file:</label>
|
|
26
|
+
<input type="file" id="fileUpload" name="fileUpload"><br><br>
|
|
27
|
+
<div id="result" class="style"></div><br />
|
|
28
|
+
<input type="submit" value="Submit" onclick="onClick()">
|
|
29
|
+
|
|
30
|
+
</body>
|
|
31
|
+
|
|
32
|
+
</html>
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<body>
|
|
13
13
|
<h1>Follow Link</h1>
|
|
14
14
|
<div id="result" class="style">
|
|
15
|
-
Please click <a href="about-us.html">About us link</a> for more information.
|
|
15
|
+
Please click <a id="aboutUs" 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,22 @@
|
|
|
1
|
+
var reporter = require('cucumber-html-reporter');
|
|
2
|
+
|
|
3
|
+
var options = {
|
|
4
|
+
theme: 'bootstrap',
|
|
5
|
+
jsonFile: 'tests/reports/cucumber_report.json',
|
|
6
|
+
output: 'tests/reports/cucumber_report.html',
|
|
7
|
+
reportSuiteAsScenarios: true,
|
|
8
|
+
scenarioTimestamp: true,
|
|
9
|
+
launchReport: true,
|
|
10
|
+
brandTitle: "Test Report",
|
|
11
|
+
metadata: {
|
|
12
|
+
"App Version": "7.1.0",
|
|
13
|
+
"Test Environment": "development",
|
|
14
|
+
"Browser": "Google Chrome",
|
|
15
|
+
"Platform": "Linux",
|
|
16
|
+
"Parallel": "Scenarios",
|
|
17
|
+
"Executed": "Remote"
|
|
18
|
+
},
|
|
19
|
+
failedSummaryReport: true,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
reporter.generate(options);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports.assertion = function (checkbox, negativeCase) {
|
|
3
|
+
|
|
4
|
+
browser.element('css selector', checkbox, function (result) {
|
|
5
|
+
if (result.status === 0) {
|
|
6
|
+
if (negativeCase) {
|
|
7
|
+
return browser.expect.element(checkbox).to.not.be.selected;
|
|
8
|
+
}
|
|
9
|
+
return browser.expect.element(checkbox).to.be.selected;
|
|
10
|
+
} else {
|
|
11
|
+
browser.element('css selector', '#' + checkbox, function (result) {
|
|
12
|
+
if (result.status === 0) {
|
|
13
|
+
if (negativeCase) {
|
|
14
|
+
return browser.expect.element('#' + checkbox).to.not.be.selected;
|
|
15
|
+
}
|
|
16
|
+
return browser.expect.element('#' + checkbox).to.be.selected;
|
|
17
|
+
} else {
|
|
18
|
+
browser.element('css selector', 'input[name="' + checkbox + '"]', function (result) {
|
|
19
|
+
if (result.status === 0) {
|
|
20
|
+
if (negativeCase) {
|
|
21
|
+
return browser.expect.element('input[name="' + checkbox + '"]').to.not.be.selected;
|
|
22
|
+
}
|
|
23
|
+
return browser.expect.element('input[name="' + checkbox + '"]').to.be.selected;
|
|
24
|
+
} else {
|
|
25
|
+
browser.element('css selector', 'input[value="' + checkbox + '"]', function (result) {
|
|
26
|
+
if (result.status === 0) {
|
|
27
|
+
if (negativeCase) {
|
|
28
|
+
return browser.expect.element('input[value="' + checkbox + '"]').to.not.be.selected;
|
|
29
|
+
}
|
|
30
|
+
return browser.expect.element('input[value="' + checkbox + '"]').to.be.selected;
|
|
31
|
+
} else {
|
|
32
|
+
browser.elements('css selector', 'label', function (elements) {
|
|
33
|
+
elements.value.forEach(function (elementsObj) {
|
|
34
|
+
browser.elementIdText(elementsObj.ELEMENT, function (result) {
|
|
35
|
+
if (result.value == checkbox) {
|
|
36
|
+
browser.getAttribute(elementsObj, "for", function (forVal) {
|
|
37
|
+
if (negativeCase) {
|
|
38
|
+
return browser.expect.element('#' + forVal.value).to.not.be.selected;
|
|
39
|
+
}
|
|
40
|
+
return browser.expect.element('#' + forVal.value).to.be.selected;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports.command = function (fileUrl, element) {
|
|
3
|
+
browser.element('css selector', element, function (result) {
|
|
4
|
+
if (result.status === 0) {
|
|
5
|
+
browser.setValue(element, require('path').resolve(__dirname + fileUrl));
|
|
6
|
+
} else {
|
|
7
|
+
browser.element('css selector', '#' + element, function (result) {
|
|
8
|
+
if (result.status === 0) {
|
|
9
|
+
browser.setValue('#' + element, require('path').resolve(__dirname + fileUrl))
|
|
10
|
+
} else {
|
|
11
|
+
browser.element('css selector', '.' + element, function (result) {
|
|
12
|
+
if (result.status === 0) {
|
|
13
|
+
browser.setValue('.' + element, require('path').resolve(__dirname + fileUrl))
|
|
14
|
+
} else {
|
|
15
|
+
browser.element('css selector', 'input[name="' + element + '"]', function (result) {
|
|
16
|
+
if (result.status === 0) {
|
|
17
|
+
browser.setValue('input[name="' + element + '"]', require('path').resolve(__dirname + fileUrl))
|
|
18
|
+
} else {
|
|
19
|
+
browser.elements('css selector', 'label', function (elements) {
|
|
20
|
+
elements.value.forEach(function (elementsObj) {
|
|
21
|
+
browser.elementIdText(elementsObj.ELEMENT, function (result) {
|
|
22
|
+
if (result.value == element) {
|
|
23
|
+
browser.getAttribute(elementsObj, "for", function (forVal) {
|
|
24
|
+
browser.setValue(forVal.value, require('path').resolve(__dirname + fileUrl))
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webship-js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"description": "Webship JS automated functional testing.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"node": ">= 16.0"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
|
-
"test": "nightwatch --format @cucumber/pretty-formatter --format-options '{\"colorsEnabled\": true}' --format-options '{\"theme\": {\"feature keyword\":[\"bold\",\"blue\"],\"feature name\":[\"blue\",\"underline\"],\"feature description\":[\"blueBright\"],\"scenario keyword\":[\"bold\",\"magenta\"],\"scenario name\":[\"magenta\",\"underline\"],\"step keyword\":[\"bold\",\"green\"],\"step text\":[\"greenBright\",\"italic\"]}}' --format json:./tests/reports/
|
|
14
|
+
"test": "nightwatch --format @cucumber/pretty-formatter --format-options '{\"colorsEnabled\": true}' --format-options '{\"theme\": {\"feature keyword\":[\"bold\",\"blue\"],\"feature name\":[\"blue\",\"underline\"],\"feature description\":[\"blueBright\"],\"scenario keyword\":[\"bold\",\"magenta\"],\"scenario name\":[\"magenta\",\"underline\"],\"step keyword\":[\"bold\",\"green\"],\"step text\":[\"greenBright\",\"italic\"]}}' --format json:./tests/reports/cucumber_report.json; node generate-reports.js;",
|
|
15
15
|
"lint:js": "node ./node_modules/eslint/bin/eslint.js --config=.eslintrc.json .",
|
|
16
16
|
"build": "webpack",
|
|
17
17
|
"start": "npm run devServer",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"@cucumber/cucumber": "*",
|
|
33
33
|
"@cucumber/pretty-formatter": "^1.0.0-alpha.2",
|
|
34
34
|
"args-parser": "~1.0",
|
|
35
|
+
"cucumber-html-reporter": "^7.1.0",
|
|
35
36
|
"eslint": "~8.0",
|
|
36
37
|
"eslint-config-airbnb-base": "~15.0",
|
|
37
38
|
"eslint-plugin-import": "~2.25",
|
|
Binary file
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Feature: Test register page
|
|
2
|
+
As a tester
|
|
3
|
+
I want to be able to test the register page work
|
|
4
|
+
|
|
5
|
+
Scenario: Check the "Then checkbox is/should be checked" step definitions
|
|
6
|
+
Given I am on "test--then--the-checkbox-checked.html"
|
|
7
|
+
When I press "Register"
|
|
8
|
+
Then the "PrivacyPolicy" checkbox should not be checked
|
|
9
|
+
And the "rememberMe" checkbox is not checked
|
|
10
|
+
And I should see "Please check Agree to Privacy Policy"
|
|
11
|
+
When I check "PrivacyPolicy"
|
|
12
|
+
And I press "Register"
|
|
13
|
+
Then the checkbox "PrivacyPolicy" should be checked
|
|
14
|
+
And I should see "Registration Done Successfully"
|
|
15
|
+
When I check "rememberMe"
|
|
16
|
+
Then the checkbox "Remember me" is checked
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Feature: Example test for: Then the "filed" should contain "value"
|
|
2
|
+
As a tester
|
|
3
|
+
I want to be able to check field if has a particular value or not
|
|
4
|
+
|
|
5
|
+
Scenario: Check field if has a particular value or not
|
|
6
|
+
Given I am on homepage
|
|
7
|
+
When I go to "test--then--i-should--not--see-text-in-element.html"
|
|
8
|
+
And I fill in "Username" with "user1"
|
|
9
|
+
Then the "Username" field should contain "user1"
|
|
10
|
+
When I press "Reset"
|
|
11
|
+
And I fill in "Username" with "user2"
|
|
12
|
+
Then the "Username" field should not contain "user1"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Feature: Example test for "When I attach file to field"
|
|
2
|
+
|
|
3
|
+
As a tester
|
|
4
|
+
I want to be able to attach file (images) to feild
|
|
5
|
+
|
|
6
|
+
Scenario: Check the "When I attach file to feild" step definitions
|
|
7
|
+
Given I am on "test--when--i-attach-file-to-feild.html"
|
|
8
|
+
When I attach the file "../../../tests/assets/webshipco.png" to "#fileUpload"
|
|
9
|
+
When I press "Submit"
|
|
10
|
+
Then I should see "webshipco.png"
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
Feature: Example test for "When I follow 'link'"
|
|
1
|
+
Feature: Example test for "When I follow 'link'"
|
|
2
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
|
|
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
6
|
|
|
7
7
|
Scenario: Check the "When I follow link" step definitions
|
|
8
8
|
Given I am on "test--when--i-follow-link.html"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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"
|
|
@@ -4,7 +4,6 @@ const { Then } = require('@cucumber/cucumber');
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Opens homepage.
|
|
7
|
-
*
|
|
8
7
|
* Example: Given I am on homepage
|
|
9
8
|
* Example: Given I am on the homepage
|
|
10
9
|
*
|
|
@@ -15,7 +14,7 @@ Given(/^I am on( the)* homepage$/, function (url) {
|
|
|
15
14
|
});
|
|
16
15
|
|
|
17
16
|
/**
|
|
18
|
-
*
|
|
17
|
+
* Open specific page
|
|
19
18
|
* Example: Given I am on "about-us.html"
|
|
20
19
|
*
|
|
21
20
|
* @Given /^I am on "([^"]*)?"$/
|
|
@@ -25,7 +24,7 @@ Given(/^I am on "([^"]*)?"$/, function (url) {
|
|
|
25
24
|
});
|
|
26
25
|
|
|
27
26
|
/**
|
|
28
|
-
*
|
|
27
|
+
* Go to homepage
|
|
29
28
|
* Example: When I go to the homepage
|
|
30
29
|
* Example: And I go to "/"
|
|
31
30
|
*
|
|
@@ -36,7 +35,7 @@ When(/^I go to( the)* homepage$/, function () {
|
|
|
36
35
|
});
|
|
37
36
|
|
|
38
37
|
/**
|
|
39
|
-
*
|
|
38
|
+
* Go to specific page
|
|
40
39
|
* Example: When I go to "contact-us.html"
|
|
41
40
|
*
|
|
42
41
|
* @When /^I go to "([^"]*)?"$/
|
|
@@ -64,7 +63,7 @@ Then(/^I should( not)* see "([^"]*)?"$/, function (negativeCase, expectedText) {
|
|
|
64
63
|
|
|
65
64
|
/**
|
|
66
65
|
* Moves forward one page in history
|
|
67
|
-
* Example:
|
|
66
|
+
* Example: When I move forward one page
|
|
68
67
|
*
|
|
69
68
|
* @When /^I move forward one page$/
|
|
70
69
|
*/
|
|
@@ -83,7 +82,7 @@ When(/^I move backward one page$/, function () {
|
|
|
83
82
|
});
|
|
84
83
|
|
|
85
84
|
/**
|
|
86
|
-
* Presses button with specified id|name|title|
|
|
85
|
+
* Presses button with specified id|class|name|title|value
|
|
87
86
|
* Example: When I press "Log In"
|
|
88
87
|
* Example: And I press "Log In"
|
|
89
88
|
*
|
|
@@ -95,15 +94,14 @@ When(/^I press "([^"]*)?"$/, function (elementValue) {
|
|
|
95
94
|
});
|
|
96
95
|
|
|
97
96
|
/**
|
|
98
|
-
* Clicks link with specified id|title|
|
|
99
|
-
* Example: When I follow "
|
|
97
|
+
* Clicks link with specified id|class|name|title|text
|
|
98
|
+
* Example: When I follow "Contact Us"
|
|
100
99
|
* Example: And I follow "Log In"
|
|
101
100
|
*
|
|
102
101
|
* @When /^I follow "([^"]*)?"$/
|
|
103
102
|
*/
|
|
104
|
-
When(/^I follow "([^"]*)?"$/, function (
|
|
105
|
-
browser.
|
|
106
|
-
// return browser.smartLinkClick(elementValue);
|
|
103
|
+
When(/^I follow "([^"]*)?"$/, function (item) {
|
|
104
|
+
browser.smartLinkFollow(item);
|
|
107
105
|
});
|
|
108
106
|
|
|
109
107
|
/**
|
|
@@ -118,8 +116,8 @@ When(/^I reload( the)* page$/, function (url) {
|
|
|
118
116
|
});
|
|
119
117
|
|
|
120
118
|
/**
|
|
121
|
-
*
|
|
122
|
-
* Example: When I fill in "
|
|
119
|
+
* Define the step of filling values in the form field specified by id|class|name|label.
|
|
120
|
+
* Example: When I fill in "Username" with "John Smith"
|
|
123
121
|
*
|
|
124
122
|
* @When /^I fill in "([^"]*)?" with "([^"]*)?"$/
|
|
125
123
|
*/
|
|
@@ -128,7 +126,7 @@ When(/^I fill in "([^"]*)?" with "([^"]*)?"$/, function (field, value) {
|
|
|
128
126
|
});
|
|
129
127
|
|
|
130
128
|
/**
|
|
131
|
-
* Fills in form field with specified id|name|label
|
|
129
|
+
* Fills in form field with specified id|class|name|label
|
|
132
130
|
* Example: When I fill in "username" with:
|
|
133
131
|
*
|
|
134
132
|
* @When /^I fill in "([^"]*)?" with:$/
|
|
@@ -138,7 +136,7 @@ When(/^I fill in "([^"]*)?" with:$/, function (field) {
|
|
|
138
136
|
});
|
|
139
137
|
|
|
140
138
|
/**
|
|
141
|
-
* Fills in form field with specified id|name|label
|
|
139
|
+
* Fills in form field with specified id|class|name|label
|
|
142
140
|
* Example: And I fill in "webshipco" for "username"
|
|
143
141
|
*
|
|
144
142
|
* @When /^I fill in "([^"]*)?" for "([^"]*)?"$/
|
|
@@ -167,9 +165,8 @@ When(/^I fill in the following:$/, function (table) {
|
|
|
167
165
|
});
|
|
168
166
|
|
|
169
167
|
/**
|
|
170
|
-
* Selects option in select field with specified id|name|label
|
|
171
|
-
* Example: When I select "
|
|
172
|
-
* Example: And I select "saab" from "Cars"
|
|
168
|
+
* Selects option in select field with specified id|class|name|label
|
|
169
|
+
* Example: When I select "mercedes" from "Cars"
|
|
173
170
|
*
|
|
174
171
|
* @When /^I select "([^"]*)?" from "([^"]*)?"$/
|
|
175
172
|
*/
|
|
@@ -178,9 +175,8 @@ When(/^I select "([^"]*)?" from "([^"]*)?"$/, function (option, selectBox) {
|
|
|
178
175
|
});
|
|
179
176
|
|
|
180
177
|
/**
|
|
181
|
-
* Checks checkbox
|
|
182
|
-
* Example: When I check "
|
|
183
|
-
* Example: And I check "Pearl Necklace"
|
|
178
|
+
* Checks checkbox specified by id|class|name|label
|
|
179
|
+
* Example: When I check "Remember me"
|
|
184
180
|
*
|
|
185
181
|
* @When /^I check "([^"]*)?"$/
|
|
186
182
|
*/
|
|
@@ -189,9 +185,8 @@ When(/^I check "([^"]*)?"$/, function (item) {
|
|
|
189
185
|
});
|
|
190
186
|
|
|
191
187
|
/**
|
|
192
|
-
* Unchecks checkbox
|
|
193
|
-
* Example: When I uncheck "
|
|
194
|
-
* Example: And I uncheck "Broadway Plays"
|
|
188
|
+
* Unchecks checkbox specified by id|class|name|label
|
|
189
|
+
* Example: When I uncheck "Remember me"
|
|
195
190
|
*
|
|
196
191
|
* @When /^I uncheck "([^"]*)?"$/
|
|
197
192
|
*/
|
|
@@ -200,9 +195,8 @@ When(/^I uncheck "([^"]*)?"$/, function (item) {
|
|
|
200
195
|
});
|
|
201
196
|
|
|
202
197
|
/**
|
|
203
|
-
*
|
|
198
|
+
* Verify, that current page is the homepage
|
|
204
199
|
* Example: Then I should be on the homepage
|
|
205
|
-
* Example: And I should be on the homepage
|
|
206
200
|
*
|
|
207
201
|
* @Then /^I should be on( the)* homepage$/
|
|
208
202
|
*/
|
|
@@ -211,9 +205,9 @@ Then(/^I should be on( the)* homepage$/, function (url) {
|
|
|
211
205
|
});
|
|
212
206
|
|
|
213
207
|
/**
|
|
214
|
-
*
|
|
208
|
+
* Verify, that current page path is equal to specified
|
|
215
209
|
* Example: Then I should be on "/"
|
|
216
|
-
* Example: And I should be on "/
|
|
210
|
+
* Example: And I should be on "/user/login"
|
|
217
211
|
* Example: And I should be on "http://google.com"
|
|
218
212
|
*
|
|
219
213
|
* @Then /^I should be on "([^"]*)?"$/
|
|
@@ -223,9 +217,9 @@ Then(/^I should be on "([^"]*)?"$/, function (url) {
|
|
|
223
217
|
});
|
|
224
218
|
|
|
225
219
|
/**
|
|
226
|
-
* Checks, that HTML response contains specified
|
|
227
|
-
* Example: Then the response should contain "
|
|
228
|
-
* Example:
|
|
220
|
+
* Checks, that HTML response contains specific text specified by id|class|name|label
|
|
221
|
+
* Example: Then the response should contain "Welcome visitor, How can I help you?"
|
|
222
|
+
* Example: Then the response should not contain "Error: Ambiguous messages that are unclear"
|
|
229
223
|
*
|
|
230
224
|
* @Then /^the response should contain "([^"]*)?"$/
|
|
231
225
|
*/
|
|
@@ -238,9 +232,9 @@ Then(/^the response should( not)* contain "([^"]*)?"$/, function (negativeCase,
|
|
|
238
232
|
});
|
|
239
233
|
|
|
240
234
|
/**
|
|
241
|
-
*
|
|
242
|
-
* Example: Then I should see "
|
|
243
|
-
* Example:
|
|
235
|
+
* Assert, that element contains a specific text value specified by id|class|name|label
|
|
236
|
+
* Example: Then I should see "John Smith" in the "Username" element
|
|
237
|
+
* Example: Then I should see "Joe Smith" in the "Username" element
|
|
244
238
|
*
|
|
245
239
|
* @Then /^I should( not)* see "([^"]*)?" in the "([^"]*)?" element$/
|
|
246
240
|
*/
|
|
@@ -249,9 +243,9 @@ Then(/^I should( not)* see "([^"]*)?" in the "([^"]*)?" element$/, function (neg
|
|
|
249
243
|
});
|
|
250
244
|
|
|
251
245
|
/**
|
|
252
|
-
*
|
|
253
|
-
* Example: Then I should see text matching "
|
|
254
|
-
* Example:
|
|
246
|
+
* Assert, that page contains text matching specified pattern
|
|
247
|
+
* Example: Then I should see text matching "Welcome visitor, How can I help you?"
|
|
248
|
+
* Example: Then I should not see text matching "Error: Ambiguous messages that are unclear"
|
|
255
249
|
*
|
|
256
250
|
* @Then /^I should( not)* see text matching "([^"]*)?"$/
|
|
257
251
|
*/
|
|
@@ -264,9 +258,8 @@ Then(/^I should( not)* see text matching "([^"]*)?"$/, function (negativeCase, e
|
|
|
264
258
|
});
|
|
265
259
|
|
|
266
260
|
/**
|
|
267
|
-
*
|
|
261
|
+
* Assert, that element exists on page specified by id|class|name|label
|
|
268
262
|
* Example: Then I should see a "body" element
|
|
269
|
-
* Example: And I should see a "body" element
|
|
270
263
|
*
|
|
271
264
|
* @Then /^I should( not)* see a(n)* "([^"]*)?" element$/
|
|
272
265
|
*/
|
|
@@ -278,12 +271,77 @@ Then(/^I should( not)* see a(n)* "([^"]*)?" element$/, function (negativeCase, i
|
|
|
278
271
|
});
|
|
279
272
|
|
|
280
273
|
/**
|
|
281
|
-
*
|
|
282
|
-
* Example: Then the "body" element should contain "color:
|
|
283
|
-
* Example: And the "body" element should contain "color:black;"
|
|
274
|
+
* Assert, that element contains a specific CSS style specified by id|class|name|label|tag.
|
|
275
|
+
* Example: Then the "body" element should contain "color:white;"
|
|
284
276
|
*
|
|
285
277
|
* @Then /^the "([^"]*)?" element should( not)* contain "([^"]*)?"$/
|
|
286
278
|
*/
|
|
287
279
|
Then(/^the "([^"]*)?" element should( not)* contain "([^"]*)?"$/, function (element, negativeCase, elementCss) {
|
|
288
280
|
return browser.assert.smartElementContainsCss(element, negativeCase, elementCss);
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Attaches file to field with specified id|class|name|label
|
|
285
|
+
* Example: When I attach the file "profileIcon.jpg" to "profileIconUpload"
|
|
286
|
+
*
|
|
287
|
+
* @When /^I attach the file "([^"]*)?" to "([^"]*)?"$/
|
|
288
|
+
*/
|
|
289
|
+
When(/^I attach the file "([^"]*)?" to "([^"]*)?"$/, function (fileUrl, element) {
|
|
290
|
+
browser.smartUploadFile(fileUrl, element);
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Assert, that form field with specified id|class|name|label has specified value
|
|
295
|
+
* Example: Then the "username" field should contain "John Smith"
|
|
296
|
+
*
|
|
297
|
+
* @Then /^the "([^"]*)?" field should( not)* contain "([^"]*)?"$/
|
|
298
|
+
*/
|
|
299
|
+
Then(/^the "([^"]*)?" field should( not)* contain "([^"]*)?"$/, function (field, negativeCase, expectedText) {
|
|
300
|
+
return browser.assert.smartElementContains(negativeCase, expectedText, field);
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Assert, that checkbox with specified id|class|name|label is should be checked
|
|
305
|
+
* Example: Then the "PrivacyPolicy" checkbox should be checked
|
|
306
|
+
*
|
|
307
|
+
* @Then /^the "([^"]*)?" checkbox should(not)* be checked$/
|
|
308
|
+
*
|
|
309
|
+
*/
|
|
310
|
+
Then(/^the "([^"]*)?" checkbox should( not)* be checked$/, function (checkbox, negativeCase) {
|
|
311
|
+
return browser.assert.smartCheckboxChecked(checkbox, negativeCase);
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Check, whether the checkbox specified by id|class|name|label is checked or not.
|
|
316
|
+
* Example: Then the "Remember Me" checkbox is checked
|
|
317
|
+
*
|
|
318
|
+
* @Then /^the "([^"]*)?" checkbox is( not)* checked$/
|
|
319
|
+
*
|
|
320
|
+
*/
|
|
321
|
+
Then(/^the "([^"]*)?" checkbox is( not)* checked$/, function (checkbox, negativeCase) {
|
|
322
|
+
return browser.assert.smartCheckboxChecked(checkbox, negativeCase);
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Assert, that checkbox with specified id|name|label|value is checked
|
|
327
|
+
* Example: Then the checkbox "PrivacyPolicy" should be checked
|
|
328
|
+
* Example: Then the checkbox "PrivacyPolicy" should not be checked
|
|
329
|
+
*
|
|
330
|
+
* @Then /^the checkbox "([^"]*)?" should(not)* be checked$/
|
|
331
|
+
*
|
|
332
|
+
*/
|
|
333
|
+
Then(/^the checkbox "([^"]*)?" should( not)* be checked$/, function (checkbox, negativeCase) {
|
|
334
|
+
return browser.assert.smartCheckboxChecked(checkbox, negativeCase);
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Assert, that checkbox with specified id|name|label|value is checked
|
|
339
|
+
* Example: Then the checkbox "Remember Me" is checked
|
|
340
|
+
* Example: And the checkbox "Remember Me" is not checked
|
|
341
|
+
*
|
|
342
|
+
* @Then /^the checkbox "([^"]*)?" is( not)* checked$/
|
|
343
|
+
*
|
|
344
|
+
*/
|
|
345
|
+
Then(/^the checkbox "([^"]*)?" is( not)* checked$/, function (checkbox, negativeCase) {
|
|
346
|
+
return browser.assert.smartCheckboxChecked(checkbox, negativeCase);
|
|
289
347
|
});
|
package/webship-init.js
CHANGED
|
@@ -9,13 +9,13 @@ var projectPath = '';
|
|
|
9
9
|
const currentPath = process.argv[1].split("node_modules");
|
|
10
10
|
basePath = currentPath[0].substring(0, currentPath[0].lastIndexOf("/")) + '/';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
if (currentPath.length > 1) {
|
|
13
|
+
projectPath = basePath + "node_modules/webship-js/";
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
projectPath = basePath;
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* -----------------------------------------------------
|
|
@@ -36,16 +36,16 @@ parser.add_argument('-ci', '--continuous_integration',
|
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
parser.add_argument('-b', '--browser',
|
|
39
|
-
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
39
|
+
{
|
|
40
|
+
help: 'Add your Browser (chrome, firefox), By default: -b chrome',
|
|
41
|
+
default: 'chrome',
|
|
42
|
+
});
|
|
43
43
|
|
|
44
44
|
parser.add_argument('-os', '--operating_system',
|
|
45
|
-
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
45
|
+
{
|
|
46
|
+
help: 'Add your Operating System (linux, mac, windows), By default: -os linux',
|
|
47
|
+
default: 'linux',
|
|
48
|
+
});
|
|
49
49
|
|
|
50
50
|
var argsParse = parser.parse_args();
|
|
51
51
|
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
module.exports.command = function (elementValue) {
|
|
3
|
-
|
|
4
|
-
browser.element('css selector', elementValue, function (result) {
|
|
5
|
-
if (result.status === 0) {
|
|
6
|
-
return browser.click(elementValue);
|
|
7
|
-
}
|
|
8
|
-
else {
|
|
9
|
-
browser.click("link text", elementValue);
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
}
|