webship-js 1.0.20 → 1.0.22
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 +2 -2
- package/bitbucket-pipelines.yml +26 -0
- package/examples/example-api.json +28 -0
- package/examples/existing-page.html +11 -0
- package/examples/index.html +1 -1
- package/examples/test--then--i-should--see-text-matching-pattern.html +31 -0
- package/examples/test--when--i-press-button.html +1 -1
- package/examples/test--when--i-reload-page.html +1 -1
- package/lib/custom-assertions/textMatching.js +12 -0
- package/lib/custom-commands/smartSelectOption.js +8 -8
- package/nightwatch.conf.js +1 -1
- package/package.json +5 -6
- package/tests/features/test--given--i-am-on-homepage.feature +8 -8
- package/tests/features/test--then--i-should--not--see-text-in-element.feature +10 -6
- package/tests/features/test--then--i-should--see-text-matching-pattern-in-element.feature +18 -0
- package/tests/features/test--then--i-should--see-text-matching-pattern.feature +18 -0
- package/tests/features/test--then--i-should-be-on-page.feature +6 -6
- package/tests/features/test--then--i-should-be-on-the-homepage.feature +5 -4
- package/tests/features/test--then--i-should-see-an-element.feature +4 -5
- package/tests/features/test--then--the-checkbox-is-checked.feature +18 -0
- package/tests/features/test--then--the-checkbox-should-be-checked.feature +16 -0
- package/tests/features/test--then--the-element-should_not-contain-cssproperty.feature +11 -8
- package/tests/features/test--then--the-field-should-contain-value.feature +3 -4
- package/tests/features/test--then--the-response-should-contain.feature +3 -3
- package/tests/features/test--then--the-response-status-code-should-be.feature +31 -0
- package/tests/features/test--when--i-attach-file-to-feild.feature +5 -5
- package/tests/features/test--when--i-check-checkbox.feature +4 -4
- package/tests/features/test--when--i-click-link.feature +6 -7
- package/tests/features/test--when--i-fill-in.feature +13 -18
- package/tests/features/test--when--i-move-forward-backward-one-page.feature +8 -7
- package/tests/features/test--when--i-press-button.feature +7 -9
- package/tests/features/test--when--i-reload-page.feature +5 -7
- package/tests/features/test--when--i-select-option-from-dropdownlist.feature +12 -0
- package/tests/features/test--when--i-uncheck-checkbox.feature +5 -7
- package/tests/features/test--when--i-wait-time.feature +2 -2
- package/tests/step-definitions/webship.js +154 -104
- package/bitbucket-pipelines-test.yml +0 -34
- package/tests/features/test--then--i-should-see-text-matching.feature +0 -8
- package/tests/features/test--then--the-checkbox-checked.feature +0 -16
- package/tests/features/test--when--i-select-option-from-selectbox.feature +0 -13
- /package/examples/{test--when--i-select-option-from-selectbox.html → test--when--i-select-option-from-dropdownlist.html} +0 -0
package/.circleci/config.yml
CHANGED
|
@@ -62,9 +62,9 @@ commands:
|
|
|
62
62
|
- run:
|
|
63
63
|
name: Run Selenium Standalone server
|
|
64
64
|
command: |
|
|
65
|
-
if [[ ! -f /home/circleci/selenium-server-
|
|
65
|
+
if [[ ! -f /home/circleci/selenium-server-4.1.2.jar ]]; then wget -O /home/circleci/selenium-server-4.1.2.jar https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.1.0/selenium-server-4.1.2.jar; fi
|
|
66
66
|
cd /home/circleci/
|
|
67
|
-
java -jar selenium-server-
|
|
67
|
+
java -jar selenium-server-4.1.2.jar standalone
|
|
68
68
|
background: true
|
|
69
69
|
|
|
70
70
|
jobs:
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
image: node:16 # Choose an appropriate Node.js version
|
|
2
|
+
|
|
3
|
+
pipelines:
|
|
4
|
+
default:
|
|
5
|
+
- step:
|
|
6
|
+
name: Install and Test
|
|
7
|
+
caches:
|
|
8
|
+
- node
|
|
9
|
+
script:
|
|
10
|
+
- npm install # Install your Node.js dependencies
|
|
11
|
+
- npm install selenium-webdriver --save # Install the Selenium WebDriver
|
|
12
|
+
- npm install chromedriver --save # Install ChromeDriver (for running tests in Chrome)
|
|
13
|
+
# Add other dependencies as needed
|
|
14
|
+
|
|
15
|
+
# Set up your test environment here (e.g., starting a server, configuring the application)
|
|
16
|
+
# For example, if you have a start script defined in your package.json:
|
|
17
|
+
# - npm run start & # Start your server in the background
|
|
18
|
+
|
|
19
|
+
# Run your tests here, assuming you have a test script defined in your package.json:
|
|
20
|
+
- yarn install
|
|
21
|
+
- yarn test
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"data": [{
|
|
3
|
+
"type": "articles",
|
|
4
|
+
"id": "1",
|
|
5
|
+
"attributes": {
|
|
6
|
+
"title": "JSON:API paints my bikeshed!",
|
|
7
|
+
"body": "The shortest article. Ever.",
|
|
8
|
+
"created": "2015-05-22T14:56:29.000Z",
|
|
9
|
+
"updated": "2015-05-22T14:56:28.000Z"
|
|
10
|
+
},
|
|
11
|
+
"relationships": {
|
|
12
|
+
"author": {
|
|
13
|
+
"data": {"id": "42", "type": "people"}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}],
|
|
17
|
+
"included": [
|
|
18
|
+
{
|
|
19
|
+
"type": "people",
|
|
20
|
+
"id": "42",
|
|
21
|
+
"attributes": {
|
|
22
|
+
"name": "John",
|
|
23
|
+
"age": 80,
|
|
24
|
+
"gender": "male"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
package/examples/index.html
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
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-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
|
-
<li><a href="test--when--i-select-option-from-
|
|
22
|
+
<li><a href="test--when--i-select-option-from-dropdownlist.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>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset='utf-8'>
|
|
6
|
+
<title>Text Matching Pattern</title>
|
|
7
|
+
<style>
|
|
8
|
+
.container,
|
|
9
|
+
.container input,
|
|
10
|
+
.container button {
|
|
11
|
+
font-size: 26px;
|
|
12
|
+
}
|
|
13
|
+
</style>
|
|
14
|
+
|
|
15
|
+
</head>
|
|
16
|
+
|
|
17
|
+
<body>
|
|
18
|
+
<h1>Text Matching Pattern</h1>
|
|
19
|
+
|
|
20
|
+
<div class="container">
|
|
21
|
+
<p>Email:</p><p>info@webship.co</p>
|
|
22
|
+
<p>Telephone:</p><p>0796-778899</p>
|
|
23
|
+
<p>Password conditions:</p><p>Pa$$word2023</p>
|
|
24
|
+
<div class="time"><p>Time:</p><p>10:30 AM</p></div>
|
|
25
|
+
<div id="date"><p>Date (Number):</p><p>22-03-2023</p></div>
|
|
26
|
+
<div id="countryCode"><p>Country code:</p><p id="ccode">JOR</p></div>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
</body>
|
|
30
|
+
|
|
31
|
+
</html>
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
<h1>Press Button</h1>
|
|
24
24
|
<div id="result" class="style"></div><br/>
|
|
25
25
|
<label for="btnClickid">Press button</label>
|
|
26
|
-
<input id="btnClickid" class="btnClickclass" name="btnClickname" type="button" value="
|
|
26
|
+
<input id="btnClickid" class="btnClickclass" name="btnClickname" type="button" value="Submit" onclick="onClick()">
|
|
27
27
|
</body>
|
|
28
28
|
</html>
|
|
@@ -22,6 +22,6 @@
|
|
|
22
22
|
<body>
|
|
23
23
|
<h1>Press Button</h1>
|
|
24
24
|
<div id="result" class="style"></div><br/>
|
|
25
|
-
<input id="btnClick" class="btnClick" name="btnClick" type="button" value="
|
|
25
|
+
<input id="btnClick" class="btnClick" name="btnClick" type="button" value="Submit" onclick="onClick()">
|
|
26
26
|
</body>
|
|
27
27
|
</html>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
module.exports.assertion = function (negativeCase, textPattern, element) {
|
|
3
|
+
|
|
4
|
+
browser.elements('css selector', element, function (elements) {
|
|
5
|
+
elements.value.forEach(function (elementsObj) {
|
|
6
|
+
if (negativeCase) {
|
|
7
|
+
return browser.assert.not.textMatches(elementsObj, textPattern);
|
|
8
|
+
}
|
|
9
|
+
return browser.assert.textMatches(elementsObj, textPattern);
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
|
|
2
|
-
module.exports.command = function (option,
|
|
2
|
+
module.exports.command = function (option, dropdownlist) {
|
|
3
3
|
|
|
4
|
-
browser.element('css selector',
|
|
4
|
+
browser.element('css selector', dropdownlist, function (result) {
|
|
5
5
|
if (result.status === 0) {
|
|
6
|
-
return browser.click(
|
|
6
|
+
return browser.click(dropdownlist + ' option[value=' + option + ']');
|
|
7
7
|
} else {
|
|
8
|
-
browser.element('css selector', '#' +
|
|
8
|
+
browser.element('css selector', '#' + dropdownlist, function (result) {
|
|
9
9
|
if (result.status === 0) {
|
|
10
|
-
return browser.click('#' +
|
|
10
|
+
return browser.click('#' + dropdownlist + ' option[value=' + option + ']');
|
|
11
11
|
} else {
|
|
12
|
-
browser.element('css selector', 'select[name=' +
|
|
12
|
+
browser.element('css selector', 'select[name=' + dropdownlist + ']', function (result) {
|
|
13
13
|
if (result.status === 0) {
|
|
14
|
-
return browser.click('select[name=' +
|
|
14
|
+
return browser.click('select[name=' + dropdownlist + ']' + ' option[value=' + option + ']');
|
|
15
15
|
} else {
|
|
16
16
|
browser.elements('css selector', 'label', function (elements) {
|
|
17
17
|
elements.value.forEach(function (elementsObj) {
|
|
18
18
|
browser.elementIdText(elementsObj.ELEMENT, function (result) {
|
|
19
|
-
if (result.value ==
|
|
19
|
+
if (result.value == dropdownlist) {
|
|
20
20
|
browser.getAttribute(elementsObj, "for", function (forVal) {
|
|
21
21
|
return browser.click('#' + forVal.value + ' option[value=' + option + ']');
|
|
22
22
|
});
|
package/nightwatch.conf.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webship-js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22",
|
|
4
4
|
"description": "Webship JS automated functional testing.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
@@ -37,15 +37,14 @@
|
|
|
37
37
|
"eslint-config-airbnb-base": "~15.0",
|
|
38
38
|
"eslint-plugin-import": "~2.25",
|
|
39
39
|
"lodash": "~4.17.21",
|
|
40
|
-
"webpack": "~5.0"
|
|
41
|
-
},
|
|
42
|
-
"devDependencies": {
|
|
40
|
+
"webpack": "~5.0",
|
|
43
41
|
"chromedriver": "*",
|
|
44
42
|
"geckodriver": "*",
|
|
45
43
|
"webpack-cli": "~5.0",
|
|
46
|
-
"webpack-dev-server": "~4.0"
|
|
44
|
+
"webpack-dev-server": "~4.0",
|
|
45
|
+
"request": "~2.0"
|
|
47
46
|
},
|
|
48
47
|
"bin": {
|
|
49
48
|
"steplist": "./steplist.js"
|
|
50
49
|
}
|
|
51
|
-
}
|
|
50
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
Feature:
|
|
2
|
-
As
|
|
3
|
-
I want to be able to navigate to the homepage
|
|
4
|
-
So that I can check the welcome message at homepage
|
|
1
|
+
Feature: An example to test for being on the homepage
|
|
2
|
+
As an anonymous user
|
|
3
|
+
I want to be able to navigate to the homepage
|
|
4
|
+
So that I can check the welcome message at homepage
|
|
5
5
|
|
|
6
|
-
Scenario: Check the homepage
|
|
6
|
+
Scenario: Check being on the homepage
|
|
7
7
|
Given I am on the homepage
|
|
8
|
-
|
|
8
|
+
Then I should see "Welcome to the homepage of the Webship-js Examples"
|
|
9
9
|
|
|
10
|
-
Scenario: Check
|
|
10
|
+
Scenario: Check being on homepage
|
|
11
11
|
Given I am on homepage
|
|
12
|
-
|
|
12
|
+
Then I should see "Welcome to the homepage of the Webship-js Examples"
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
Feature:
|
|
2
|
-
As a
|
|
3
|
-
I want to be able to check an element
|
|
1
|
+
Feature: An example to test whether an element contains a certain text or not
|
|
2
|
+
As a tester
|
|
3
|
+
I want to be able to check an element contains a certain text or not
|
|
4
4
|
|
|
5
|
-
Scenario: Check an element if it
|
|
6
|
-
Given I am on
|
|
7
|
-
When I go to "test--then--i-should--not--see-text-in-element.html"
|
|
5
|
+
Scenario: Check an element if it contains a specific text
|
|
6
|
+
Given I am on "/test--then--i-should--not--see-text-in-element.html"
|
|
8
7
|
And I fill in "Username" with "user1"
|
|
9
8
|
And I fill in "Password" with "1234"
|
|
10
9
|
Then I should see "user1" in the "Username" element
|
|
11
10
|
When I press "Reset"
|
|
12
11
|
And I fill in "Username" with "user2"
|
|
13
12
|
Then I should not see "user1" in the "Username" element
|
|
13
|
+
|
|
14
|
+
Scenario: Check an element if it does not contain a specific text
|
|
15
|
+
Given I am on "/test--then--i-should--not--see-text-in-element.html"
|
|
16
|
+
And I fill in "Username" with "user2"
|
|
17
|
+
Then I should not see "user1" in the "Username" element
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Feature: An example of testing match a pattern to text in a specific element
|
|
2
|
+
As a developer
|
|
3
|
+
I want to be able to check if I can see text matching the pattern I require in a specific element.
|
|
4
|
+
|
|
5
|
+
Scenario: Check if text exist in an element has a pattern match with 12-hour time format
|
|
6
|
+
Given I am on "/test--then--i-should--see-text-matching-pattern.html"
|
|
7
|
+
And I wait max of 3 seconds
|
|
8
|
+
Then I should see text matching "(((0[1-9])|(1[0-2])):([0-5])(0|5)\s(A|P|a|p)(M|m))" in the ".time" element
|
|
9
|
+
|
|
10
|
+
Scenario: Check if text exist in an element has a pattern not match with date YYYY-MM-DD
|
|
11
|
+
Given I am on "/test--then--i-should--see-text-matching-pattern.html"
|
|
12
|
+
And I wait max of 3 seconds
|
|
13
|
+
Then I should not see text matching "\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])" in the "#date" element
|
|
14
|
+
|
|
15
|
+
Scenario: Check if text exist in an element has a pattern match with date DD/MM/YYYY or DD-MM-YYYY
|
|
16
|
+
Given I am on "/test--then--i-should--see-text-matching-pattern.html"
|
|
17
|
+
And I wait max of 3 seconds
|
|
18
|
+
Then I should see text matching "(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}" in the "#date" element
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Feature: An example of testing to match a pattern to text on a specific page
|
|
2
|
+
As a developer
|
|
3
|
+
I want to be able to check if I can see text matching the pattern I require.
|
|
4
|
+
|
|
5
|
+
Scenario: Check if exist a text has a pattern match with text start with "T"
|
|
6
|
+
Given I am on "/test--then--i-should--see-text-matching-pattern.html"
|
|
7
|
+
And I wait max of 3 seconds
|
|
8
|
+
Then I should see text matching "^T\w+"
|
|
9
|
+
|
|
10
|
+
Scenario: Check if not exist a text has a pattern match with text start with "O"
|
|
11
|
+
Given I am on "/test--then--i-should--see-text-matching-pattern.html"
|
|
12
|
+
And I wait max of 3 seconds
|
|
13
|
+
Then I should not see text matching "^O\w+"
|
|
14
|
+
|
|
15
|
+
Scenario: Check if exist a text has a pattern match with Email
|
|
16
|
+
Given I am on "/test--then--i-should--see-text-matching-pattern.html"
|
|
17
|
+
And I wait max of 3 seconds
|
|
18
|
+
Then I should see text matching "[a-z0-9]+@[a-z]+\.[a-z]{2,3}"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
Feature:
|
|
2
|
-
As
|
|
3
|
-
I want to be sure I am on
|
|
1
|
+
Feature: An example to test being on a specific page
|
|
2
|
+
As an anonymous user
|
|
3
|
+
I want to be sure I am on a specific page
|
|
4
4
|
|
|
5
|
-
Scenario: Check
|
|
5
|
+
Scenario: Check being on a specific page
|
|
6
6
|
Given I am on the homepage
|
|
7
|
-
When I go to "about-us.html"
|
|
8
|
-
Then I should be on "about-us.html"
|
|
7
|
+
When I go to "/about-us.html"
|
|
8
|
+
Then I should be on "/about-us.html"
|
|
9
9
|
When I move backward one page
|
|
10
10
|
Then I should be on "/"
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
Feature:
|
|
2
|
-
As
|
|
1
|
+
Feature: An example to test being on the homepage
|
|
2
|
+
As an anonymous user
|
|
3
3
|
I want to be sure I am on the homepage
|
|
4
4
|
|
|
5
|
-
Scenario: Check
|
|
5
|
+
Scenario: Check being on the homepage
|
|
6
6
|
Given I am on the homepage
|
|
7
|
-
When I go to "about-us.html"
|
|
7
|
+
When I go to "/about-us.html"
|
|
8
8
|
And I move backward one page
|
|
9
|
+
And I wait max of 3 seconds
|
|
9
10
|
Then I should be on the homepage
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
Feature:
|
|
2
|
-
As a
|
|
1
|
+
Feature: An example to test seeing for a specific element on current page
|
|
2
|
+
As a user
|
|
3
3
|
I want to make sure that when I'm on a particular page, I should see a specific element
|
|
4
4
|
|
|
5
|
-
Scenario: Check
|
|
6
|
-
Given I am on
|
|
7
|
-
When I go to "about-us.html"
|
|
5
|
+
Scenario: Check to test seeing for a specific element
|
|
6
|
+
Given I am on "/about-us.html"
|
|
8
7
|
Then I should see a "body" element
|
|
9
8
|
And I should see a "#paragraphid" element
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Feature: An example of test for selecting a checkbox
|
|
2
|
+
As a tester
|
|
3
|
+
I want to be able to check that the checkbox is checked or not
|
|
4
|
+
|
|
5
|
+
Scenario: Check that the checkbox is checked
|
|
6
|
+
Given I am on "/test--then--the-checkbox-checked.html"
|
|
7
|
+
When I check "rememberMe"
|
|
8
|
+
And I check "PrivacyPolicy"
|
|
9
|
+
And I press "Register"
|
|
10
|
+
Then the checkbox "Remember me" is checked
|
|
11
|
+
And I should see "Registration Done Successfully"
|
|
12
|
+
|
|
13
|
+
Scenario: Check that the checkbox is not checked
|
|
14
|
+
Given I am on "/test--then--the-checkbox-checked.html"
|
|
15
|
+
When I check "PrivacyPolicy"
|
|
16
|
+
And I press "Register"
|
|
17
|
+
Then the checkbox "Remember me" is not checked
|
|
18
|
+
Then I should see "Registration Done Successfully"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Feature: An example of test assert for selecting a checkbox
|
|
2
|
+
As an anonymous user
|
|
3
|
+
I want to be sure that a specific checkbox should be checked before submitting a specific action.
|
|
4
|
+
|
|
5
|
+
Scenario: Check that the checkbox should be checked
|
|
6
|
+
Given I am on "/test--then--the-checkbox-checked.html"
|
|
7
|
+
When I check "PrivacyPolicy"
|
|
8
|
+
And I press "Register"
|
|
9
|
+
Then the checkbox "PrivacyPolicy" should be checked
|
|
10
|
+
And I should see "Registration Done Successfully"
|
|
11
|
+
|
|
12
|
+
Scenario: Check that the checkbox should not be checked
|
|
13
|
+
Given I am on "/test--then--the-checkbox-checked.html"
|
|
14
|
+
When I press "Register"
|
|
15
|
+
Then the "PrivacyPolicy" checkbox should not be checked
|
|
16
|
+
And I should see "Please check Agree to Privacy Policy"
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
Feature:
|
|
1
|
+
Feature: An example to test if the element contains a certain expected CSS property or not.
|
|
2
2
|
As a developer
|
|
3
|
-
I want to be able to test if element contains
|
|
3
|
+
I want to be able to test if the element contains a certain expected CSS property or not.
|
|
4
4
|
|
|
5
|
-
Scenario: Check element if contains
|
|
6
|
-
Given I am on
|
|
7
|
-
|
|
8
|
-
Then the "body" element should contain "background-color: lightcoral;"
|
|
9
|
-
And the "Username" element should contain "border: solid 5px red;"
|
|
5
|
+
Scenario: Check element if the element contains a certain expected CSS property
|
|
6
|
+
Given I am on "/test--then--the-element-should_not-contain-cssproperty.html"
|
|
7
|
+
Then I should see a "body" element
|
|
10
8
|
When I press "Submit"
|
|
11
9
|
Then the "body" element should contain "background-color: white;"
|
|
12
|
-
|
|
10
|
+
|
|
11
|
+
Scenario: Check element if the element not contains a certain CSS property
|
|
12
|
+
Given I am on "/test--then--the-element-should_not-contain-cssproperty.html"
|
|
13
|
+
Then I should see a "body" element
|
|
14
|
+
When I press "Submit"
|
|
15
|
+
Then the "Username" element should not contain "border: solid 5px red;"
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
Feature:
|
|
1
|
+
Feature: An example to test if the field contains certain value
|
|
2
2
|
As a tester
|
|
3
|
-
I want to be able to check field if has a
|
|
3
|
+
I want to be able to check field if has a certain value or not
|
|
4
4
|
|
|
5
5
|
Scenario: Check field if has a particular value or not
|
|
6
|
-
Given I am on
|
|
7
|
-
When I go to "test--then--i-should--not--see-text-in-element.html"
|
|
6
|
+
Given I am on "/test--then--i-should--not--see-text-in-element.html"
|
|
8
7
|
And I fill in "Username" with "user1"
|
|
9
8
|
Then the "Username" field should contain "user1"
|
|
10
9
|
When I press "Reset"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
Feature:
|
|
1
|
+
Feature: An example to test response page if contain a text
|
|
2
2
|
As a tester,
|
|
3
3
|
I want to be able to navigate to a page
|
|
4
4
|
So that I can check if this page contains a specific text
|
|
5
5
|
|
|
6
|
-
Scenario: Check
|
|
6
|
+
Scenario: Check response page if contain a text
|
|
7
7
|
Given I am on the homepage
|
|
8
8
|
Then the response should contain "Welcome to the homepage"
|
|
9
9
|
|
|
10
|
-
Scenario: Check
|
|
10
|
+
Scenario: Check response page if not contain a text
|
|
11
11
|
Given I am on the homepage
|
|
12
12
|
Then the response should not contain "Access denied"
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Feature: An example to test a page response status code
|
|
2
|
+
As a tester
|
|
3
|
+
I want to be able to test a page response status code
|
|
4
|
+
|
|
5
|
+
Scenario: Check the response status code for not existing page page
|
|
6
|
+
Given I am on the homepage
|
|
7
|
+
When I go to "/not-existing-page.html"
|
|
8
|
+
And I wait 2 seconds
|
|
9
|
+
Then the response status code should be 404
|
|
10
|
+
And the response status code should not be 200
|
|
11
|
+
|
|
12
|
+
Scenario: Check the response status code for existing page
|
|
13
|
+
Given I am on the homepage
|
|
14
|
+
When I go to "/existing-page.html"
|
|
15
|
+
And I wait 2 seconds
|
|
16
|
+
Then the response status code should not be 404
|
|
17
|
+
And the response status code should be 200
|
|
18
|
+
|
|
19
|
+
Scenario: Check the response status code for an API with JSON page format
|
|
20
|
+
Given I am on the homepage
|
|
21
|
+
When I go to "/example-api.json"
|
|
22
|
+
And I wait 2 seconds
|
|
23
|
+
Then the response status code should not be 404
|
|
24
|
+
And the response status code should be 200
|
|
25
|
+
|
|
26
|
+
Scenario: Check the response status code for a parameter of the API with JSON page format
|
|
27
|
+
Given I am on the homepage
|
|
28
|
+
When I go to "/example-api.json?include=author"
|
|
29
|
+
And I wait 2 seconds
|
|
30
|
+
Then the response status code should not be 404
|
|
31
|
+
And the response status code should be 200
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
Feature:
|
|
1
|
+
Feature: An example to test attach file to field
|
|
2
2
|
|
|
3
3
|
As a tester
|
|
4
|
-
I want to be able to attach file (images) to
|
|
4
|
+
I want to be able to attach file (images) to field
|
|
5
5
|
|
|
6
|
-
Scenario: Check
|
|
7
|
-
Given I am on "test--when--i-attach-file-to-feild.html"
|
|
8
|
-
When I attach the file "
|
|
6
|
+
Scenario: Check attach file to 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
9
|
When I press "Submit"
|
|
10
10
|
Then I should see "webshipco.png"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
Feature:
|
|
1
|
+
Feature: An example to check the checkbox
|
|
2
2
|
|
|
3
3
|
As a tester
|
|
4
|
-
I want to be able to
|
|
4
|
+
I want to be able to check a checkbox
|
|
5
5
|
|
|
6
|
-
Scenario: Check the
|
|
7
|
-
Given I am on "test--when--i-check-uncheck-checkbox.html"
|
|
6
|
+
Scenario: Check the checkbox
|
|
7
|
+
Given I am on "/test--when--i-check-uncheck-checkbox.html"
|
|
8
8
|
When I check "vehicle1"
|
|
9
9
|
And I press "Submit"
|
|
10
10
|
Then I should see "You have a Bike"
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
Feature:
|
|
1
|
+
Feature: An example to click link
|
|
2
2
|
|
|
3
3
|
As a tester
|
|
4
|
-
I want to be able to
|
|
5
|
-
it will go to the link path page
|
|
4
|
+
I want to be able to click link
|
|
6
5
|
|
|
7
|
-
Scenario: Check
|
|
8
|
-
Given I am on "test--when--i-click-link.html"
|
|
6
|
+
Scenario: Check click link by link text
|
|
7
|
+
Given I am on "/test--when--i-click-link.html"
|
|
9
8
|
When I click "About us link"
|
|
10
9
|
And I wait max of 2 seconds
|
|
11
10
|
Then I should see "About Us"
|
|
12
11
|
|
|
13
|
-
Scenario: Check
|
|
14
|
-
Given I am on "test--when--i-click-link.html"
|
|
12
|
+
Scenario: Check click link by link css class
|
|
13
|
+
Given I am on "/test--when--i-click-link.html"
|
|
15
14
|
When I click "aboutUs"
|
|
16
15
|
And I wait max of 2 seconds
|
|
17
16
|
Then I should see "About Us"
|
|
@@ -1,36 +1,31 @@
|
|
|
1
|
-
Feature:
|
|
2
|
-
As a
|
|
3
|
-
I want to be able to
|
|
4
|
-
with empty value, value for text, and fill in table
|
|
1
|
+
Feature: An example of filling the input textbox with value
|
|
2
|
+
As a tester
|
|
3
|
+
I want to be able to fill input text with value
|
|
5
4
|
|
|
6
5
|
Scenario: Check fill in input field with value
|
|
7
|
-
Given I am on
|
|
8
|
-
When I
|
|
9
|
-
When I fill in "Username" with "webshipco"
|
|
6
|
+
Given I am on "/test--when--i-fill-in.html"
|
|
7
|
+
When I fill in "Username" with "John Smith"
|
|
10
8
|
When I fill in "Password" with "1234"
|
|
11
9
|
When I press "Login"
|
|
12
|
-
Then I should see "You enter Username:
|
|
10
|
+
Then I should see "You enter Username: John Smith and Password: 1234"
|
|
13
11
|
|
|
14
12
|
Scenario: Check fill in input field with empty value
|
|
15
|
-
Given I am on
|
|
16
|
-
When I go to "test--when--i-fill-in.html"
|
|
13
|
+
Given I am on "/test--when--i-fill-in.html"
|
|
17
14
|
When I fill in "Username" with:
|
|
18
15
|
When I press "Login"
|
|
19
16
|
Then I should see "You enter Username: "
|
|
20
17
|
|
|
21
18
|
Scenario: Check fill in value for input field
|
|
22
|
-
Given I am on
|
|
23
|
-
When I
|
|
24
|
-
When I fill in "webshipco" for "Username"
|
|
19
|
+
Given I am on "/test--when--i-fill-in.html"
|
|
20
|
+
When I fill in "John Smith" for "Username"
|
|
25
21
|
When I fill in "1234" for "Password"
|
|
26
22
|
When I press "Login"
|
|
27
|
-
Then I should see "You enter Username:
|
|
23
|
+
Then I should see "You enter Username: John Smith and Password: 1234"
|
|
28
24
|
|
|
29
25
|
Scenario: Check fill in table of input fields
|
|
30
|
-
Given I am on
|
|
31
|
-
When I go to "test--when--i-fill-in.html"
|
|
26
|
+
Given I am on "/test--when--i-fill-in.html"
|
|
32
27
|
When I fill in the following:
|
|
33
|
-
| username |
|
|
28
|
+
| username | John Smith |
|
|
34
29
|
| password | 1234 |
|
|
35
30
|
When I press "Login"
|
|
36
|
-
Then I should see "You enter Username:
|
|
31
|
+
Then I should see "You enter Username: John Smith and Password: 1234"
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
Feature:
|
|
1
|
+
Feature: An example to navigate forward and backward one page
|
|
2
2
|
|
|
3
3
|
As a tester
|
|
4
|
-
I want to be able to
|
|
5
|
-
So that I know it is working
|
|
4
|
+
I want to be able to navigate forward and backward one page
|
|
6
5
|
|
|
7
|
-
Scenario: Check
|
|
6
|
+
Scenario: Check to navigate forward and backward one page
|
|
8
7
|
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
|
|
8
|
+
When I go to "/about-us.html"
|
|
12
9
|
Then I should see "About Us"
|
|
13
10
|
When I move backward one page
|
|
11
|
+
And I wait max of 3 seconds
|
|
14
12
|
Then I should see "Welcome to the homepage of the Webship-js Examples"
|
|
13
|
+
When I move forward one page
|
|
14
|
+
And I wait max of 3 seconds
|
|
15
|
+
Then I should see "About Us"
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
Feature:
|
|
1
|
+
Feature: An example to press a button
|
|
2
2
|
|
|
3
|
-
As a tester
|
|
4
|
-
I want to be able to
|
|
5
|
-
So that I know it is working
|
|
3
|
+
As a tester
|
|
4
|
+
I want to be able to press a button
|
|
6
5
|
|
|
7
|
-
Scenario: Check
|
|
8
|
-
Given I am on
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Then I should see "Button Pressed Successfully"
|
|
6
|
+
Scenario: Check press a button
|
|
7
|
+
Given I am on "/test--when--i-press-button.html"
|
|
8
|
+
When I press "Submit"
|
|
9
|
+
Then I should see "Button Pressed Successfully"
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
Feature:
|
|
1
|
+
Feature: An example to reload the page
|
|
2
2
|
|
|
3
3
|
As a tester
|
|
4
|
-
I want to be able to
|
|
5
|
-
So that I know it is working
|
|
4
|
+
I want to be able to reload the page
|
|
6
5
|
|
|
7
|
-
Scenario: Check
|
|
8
|
-
Given I am on
|
|
9
|
-
When I
|
|
10
|
-
When I press "Click Button"
|
|
6
|
+
Scenario: Check to reload the page
|
|
7
|
+
Given I am on "/test--when--i-reload-page.html"
|
|
8
|
+
When I press "Submit"
|
|
11
9
|
Then I should see "Button Pressed Successfully"
|
|
12
10
|
When I reload the page
|
|
13
11
|
Then I should not see "Button Pressed Successfully"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Feature: An example to select option from drop down list
|
|
2
|
+
|
|
3
|
+
As a tester
|
|
4
|
+
I want to be able to test select option from drop down list
|
|
5
|
+
|
|
6
|
+
Scenario: Check of selecting option from drop down list
|
|
7
|
+
Given I am on "/test--when--i-select-option-from-dropdownlist.html"
|
|
8
|
+
When I select "saab" from "cars"
|
|
9
|
+
When I press "Check select"
|
|
10
|
+
Then I should see "Option ( Saab ) has been selected successfully"
|
|
11
|
+
|
|
12
|
+
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
Feature:
|
|
1
|
+
Feature: An example to uncheck the checkbox
|
|
2
2
|
|
|
3
3
|
As a tester
|
|
4
|
-
I want to be able to
|
|
4
|
+
I want to be able to uncheck a checkbox
|
|
5
5
|
|
|
6
|
-
Scenario:
|
|
7
|
-
Given I am on "test--when--i-check-uncheck-checkbox.html"
|
|
6
|
+
Scenario: Uncheck the checkbox
|
|
7
|
+
Given I am on "/test--when--i-check-uncheck-checkbox.html"
|
|
8
8
|
When I check "I have a bike"
|
|
9
|
-
And I
|
|
10
|
-
Then I should see "You have a Bike"
|
|
11
|
-
When I check "vehicle2"
|
|
9
|
+
And I check "vehicle2"
|
|
12
10
|
And I press "Submit"
|
|
13
11
|
Then I should see "You have a Bike Car"
|
|
14
12
|
When I uncheck "Bike"
|
|
@@ -4,12 +4,12 @@ Feature: Example test for Wait a Specific/Max number of seconds/minutes for page
|
|
|
4
4
|
|
|
5
5
|
Scenario: Check page content to load
|
|
6
6
|
Given I am on the homepage
|
|
7
|
-
When I go to "test--when-i-wait-specific-time.html"
|
|
7
|
+
When I go to "/test--when-i-wait-specific-time.html"
|
|
8
8
|
And I wait 6 seconds
|
|
9
9
|
Then I should see "Welcome with waiting full time"
|
|
10
10
|
|
|
11
11
|
Scenario: Check page content to load
|
|
12
12
|
Given I am on the homepage
|
|
13
|
-
When I go to "test--when-i-wait-max-of-time.html"
|
|
13
|
+
When I go to "/test--when-i-wait-max-of-time.html"
|
|
14
14
|
And I wait max of 6 seconds
|
|
15
15
|
Then I should see "Welcome with waiting until page load"
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
const {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const {
|
|
2
|
+
Given
|
|
3
|
+
} = require('@cucumber/cucumber');
|
|
4
|
+
const {
|
|
5
|
+
When,
|
|
6
|
+
Before
|
|
7
|
+
} = require('@cucumber/cucumber');
|
|
8
|
+
const {
|
|
9
|
+
Then
|
|
10
|
+
} = require('@cucumber/cucumber');
|
|
11
|
+
|
|
12
|
+
const request = require('request');
|
|
4
13
|
|
|
5
14
|
/**
|
|
6
15
|
* Opens homepage.
|
|
@@ -170,59 +179,59 @@ When(/^I fill in the following:$/, function (table) {
|
|
|
170
179
|
*
|
|
171
180
|
* @When /^I select "([^"]*)?" from "([^"]*)?"$/
|
|
172
181
|
*/
|
|
173
|
-
When(/^I select "([^"]*)?" from "([^"]*)?"$/, function (option,
|
|
174
|
-
browser.smartSelectOption(option,
|
|
182
|
+
When(/^I select "([^"]*)?" from "([^"]*)?"$/, function (option, dropdownlist) {
|
|
183
|
+
browser.smartSelectOption(option, dropdownlist);
|
|
175
184
|
});
|
|
176
185
|
|
|
177
186
|
/**
|
|
178
|
-
* Checks checkbox specified by id|class|name|label
|
|
179
|
-
* Example: When I check "Remember me"
|
|
180
|
-
*
|
|
181
|
-
* @When /^I check "([^"]*)?"$/
|
|
182
|
-
*/
|
|
187
|
+
* Checks checkbox specified by id|class|name|label
|
|
188
|
+
* Example: When I check "Remember me"
|
|
189
|
+
*
|
|
190
|
+
* @When /^I check "([^"]*)?"$/
|
|
191
|
+
*/
|
|
183
192
|
When(/^I check "([^"]*)?"$/, function (item) {
|
|
184
193
|
browser.smartCheckItem(item);
|
|
185
194
|
});
|
|
186
195
|
|
|
187
196
|
/**
|
|
188
|
-
* Unchecks checkbox specified by id|class|name|label
|
|
189
|
-
* Example: When I uncheck "Remember me"
|
|
190
|
-
*
|
|
191
|
-
* @When /^I uncheck "([^"]*)?"$/
|
|
192
|
-
*/
|
|
197
|
+
* Unchecks checkbox specified by id|class|name|label
|
|
198
|
+
* Example: When I uncheck "Remember me"
|
|
199
|
+
*
|
|
200
|
+
* @When /^I uncheck "([^"]*)?"$/
|
|
201
|
+
*/
|
|
193
202
|
When(/^I uncheck "([^"]*)?"$/, function (item) {
|
|
194
203
|
browser.smartUncheckItem(item);
|
|
195
204
|
});
|
|
196
205
|
|
|
197
206
|
/**
|
|
198
|
-
* Verify, that current page is the homepage
|
|
199
|
-
* Example: Then I should be on the homepage
|
|
200
|
-
*
|
|
201
|
-
* @Then /^I should be on( the)* homepage$/
|
|
202
|
-
*/
|
|
207
|
+
* Verify, that current page is the homepage
|
|
208
|
+
* Example: Then I should be on the homepage
|
|
209
|
+
*
|
|
210
|
+
* @Then /^I should be on( the)* homepage$/
|
|
211
|
+
*/
|
|
203
212
|
Then(/^I should be on( the)* homepage$/, function (url) {
|
|
204
213
|
return browser.assert.urlEquals(browser.launch_url);
|
|
205
214
|
});
|
|
206
215
|
|
|
207
216
|
/**
|
|
208
|
-
* Verify, that current page path is equal to specified
|
|
209
|
-
* Example: Then I should be on "/"
|
|
210
|
-
* Example: And I should be on "/user/login"
|
|
211
|
-
* Example: And I should be on "http://google.com"
|
|
212
|
-
*
|
|
213
|
-
* @Then /^I should be on "([^"]*)?"$/
|
|
214
|
-
*/
|
|
217
|
+
* Verify, that current page path is equal to specified
|
|
218
|
+
* Example: Then I should be on "/"
|
|
219
|
+
* Example: And I should be on "/user/login"
|
|
220
|
+
* Example: And I should be on "http://google.com"
|
|
221
|
+
*
|
|
222
|
+
* @Then /^I should be on "([^"]*)?"$/
|
|
223
|
+
*/
|
|
215
224
|
Then(/^I should be on "([^"]*)?"$/, function (url) {
|
|
216
225
|
return browser.assert.urlContains(url);
|
|
217
226
|
});
|
|
218
227
|
|
|
219
228
|
/**
|
|
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"
|
|
223
|
-
*
|
|
224
|
-
* @Then /^the response should contain "([^"]*)?"$/
|
|
225
|
-
*/
|
|
229
|
+
* Checks, that HTML response contains specific text specified by id|class|name|label
|
|
230
|
+
* Example: Then the response should contain "Welcome visitor, How can I help you?"
|
|
231
|
+
* Example: Then the response should not contain "Error: Ambiguous messages that are unclear"
|
|
232
|
+
*
|
|
233
|
+
* @Then /^the response should contain "([^"]*)?"$/
|
|
234
|
+
*/
|
|
226
235
|
Then(/^the response should( not)* contain "([^"]*)?"$/, function (negativeCase, expectedText) {
|
|
227
236
|
if (negativeCase) {
|
|
228
237
|
return browser.assert.not.textContains('html', expectedText);
|
|
@@ -232,34 +241,22 @@ Then(/^the response should( not)* contain "([^"]*)?"$/, function (negativeCase,
|
|
|
232
241
|
});
|
|
233
242
|
|
|
234
243
|
/**
|
|
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
|
|
238
|
-
*
|
|
239
|
-
* @Then /^I should( not)* see "([^"]*)?" in the "([^"]*)?" element$/
|
|
240
|
-
*/
|
|
244
|
+
* Assert, that element contains a specific text value specified by id|class|name|label
|
|
245
|
+
* Example: Then I should see "John Smith" in the "Username" element
|
|
246
|
+
* Example: Then I should see "Joe Smith" in the "Username" element
|
|
247
|
+
*
|
|
248
|
+
* @Then /^I should( not)* see "([^"]*)?" in the "([^"]*)?" element$/
|
|
249
|
+
*/
|
|
241
250
|
Then(/^I should( not)* see "([^"]*)?" in the "([^"]*)?" element$/, function (negativeCase, expectedText, element) {
|
|
242
251
|
return browser.assert.smartElementContains(negativeCase, expectedText, element);
|
|
243
252
|
});
|
|
244
253
|
|
|
245
|
-
/**
|
|
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"
|
|
249
|
-
*
|
|
250
|
-
* @Then /^I should( not)* see text matching "([^"]*)?"$/
|
|
251
|
-
*/
|
|
252
|
-
Then(/^I should( not)* see text matching "([^"]*)?"$/, function (negativeCase, expectedText) {
|
|
253
|
-
if (negativeCase) {
|
|
254
|
-
return browser.assert.not.textContains('html', expectedText);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
return browser.assert.textContains('html', expectedText);
|
|
258
|
-
});
|
|
259
|
-
|
|
260
254
|
/**
|
|
261
255
|
* Assert, that element exists on page specified by id|class|name|label
|
|
262
256
|
* Example: Then I should see a "body" element
|
|
257
|
+
* Example: Then I should see an "Email" element
|
|
258
|
+
* Example: Then I should not see a "Username" element
|
|
259
|
+
* Example: Then I should not see an "img" element
|
|
263
260
|
*
|
|
264
261
|
* @Then /^I should( not)* see a(n)* "([^"]*)?" element$/
|
|
265
262
|
*/
|
|
@@ -281,13 +278,13 @@ Then(/^the "([^"]*)?" element should( not)* contain "([^"]*)?"$/, function (elem
|
|
|
281
278
|
});
|
|
282
279
|
|
|
283
280
|
/**
|
|
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
|
-
*/
|
|
281
|
+
* Attaches file to field with specified id|class|name|label
|
|
282
|
+
* Example: When I attach the file "profileIcon.jpg" to "profileIconUpload"
|
|
283
|
+
*
|
|
284
|
+
* @When /^I attach the file "([^"]*)?" to "([^"]*)?"$/
|
|
285
|
+
*/
|
|
289
286
|
When(/^I attach the file "([^"]*)?" to "([^"]*)?"$/, function (fileUrl, element) {
|
|
290
|
-
browser.smartUploadFile(fileUrl, element);
|
|
287
|
+
browser.smartUploadFile("../../../tests/assets/" + fileUrl, element);
|
|
291
288
|
});
|
|
292
289
|
|
|
293
290
|
/**
|
|
@@ -301,61 +298,60 @@ Then(/^the "([^"]*)?" field should( not)* contain "([^"]*)?"$/, function (field,
|
|
|
301
298
|
});
|
|
302
299
|
|
|
303
300
|
/**
|
|
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
|
-
*/
|
|
301
|
+
* Assert, that checkbox with specified id|class|name|label is should be checked
|
|
302
|
+
* Example: Then the "PrivacyPolicy" checkbox should be checked
|
|
303
|
+
*
|
|
304
|
+
* @Then /^the "([^"]*)?" checkbox should(not)* be checked$/
|
|
305
|
+
*
|
|
306
|
+
*/
|
|
310
307
|
Then(/^the "([^"]*)?" checkbox should( not)* be checked$/, function (checkbox, negativeCase) {
|
|
311
308
|
return browser.assert.smartCheckboxChecked(checkbox, negativeCase);
|
|
312
309
|
});
|
|
313
310
|
|
|
314
311
|
/**
|
|
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
|
-
*/
|
|
312
|
+
* Check, whether the checkbox specified by id|class|name|label is checked or not.
|
|
313
|
+
* Example: Then the "Remember Me" checkbox is checked
|
|
314
|
+
*
|
|
315
|
+
* @Then /^the "([^"]*)?" checkbox is( not)* checked$/
|
|
316
|
+
*
|
|
317
|
+
*/
|
|
321
318
|
Then(/^the "([^"]*)?" checkbox is( not)* checked$/, function (checkbox, negativeCase) {
|
|
322
319
|
return browser.assert.smartCheckboxChecked(checkbox, negativeCase);
|
|
323
320
|
});
|
|
324
321
|
|
|
325
322
|
/**
|
|
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
|
-
*/
|
|
323
|
+
* Assert, that checkbox with specified id|name|label|value is checked
|
|
324
|
+
* Example: Then the checkbox "PrivacyPolicy" should be checked
|
|
325
|
+
* Example: Then the checkbox "PrivacyPolicy" should not be checked
|
|
326
|
+
*
|
|
327
|
+
* @Then /^the checkbox "([^"]*)?" should(not)* be checked$/
|
|
328
|
+
*
|
|
329
|
+
*/
|
|
333
330
|
Then(/^the checkbox "([^"]*)?" should( not)* be checked$/, function (checkbox, negativeCase) {
|
|
334
331
|
return browser.assert.smartCheckboxChecked(checkbox, negativeCase);
|
|
335
332
|
});
|
|
336
333
|
|
|
337
334
|
/**
|
|
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
|
-
*/
|
|
335
|
+
* Assert, that checkbox with specified id|name|label|value is checked
|
|
336
|
+
* Example: Then the checkbox "Remember Me" is checked
|
|
337
|
+
* Example: And the checkbox "Remember Me" is not checked
|
|
338
|
+
*
|
|
339
|
+
* @Then /^the checkbox "([^"]*)?" is( not)* checked$/
|
|
340
|
+
*
|
|
341
|
+
*/
|
|
345
342
|
Then(/^the checkbox "([^"]*)?" is( not)* checked$/, function (checkbox, negativeCase) {
|
|
346
343
|
return browser.assert.smartCheckboxChecked(checkbox, negativeCase);
|
|
347
344
|
});
|
|
348
345
|
|
|
349
346
|
/**
|
|
350
|
-
* Wait a specific number of seconds, or a max number of seconds
|
|
351
|
-
|
|
352
|
-
* Example: When I wait
|
|
353
|
-
* Example: When I wait
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
*/
|
|
347
|
+
* Wait a specific number of seconds, or a max number of seconds until the element present.
|
|
348
|
+
* Example: When I wait 1 second
|
|
349
|
+
* Example: When I wait 5 seconds
|
|
350
|
+
* Example: When I wait max of 6 seconds
|
|
351
|
+
*
|
|
352
|
+
* @When /^I wait( max of)* "([^"]*)?" second(s)*$/
|
|
353
|
+
*
|
|
354
|
+
*/
|
|
359
355
|
When(/^I wait( max of)* (\d*) second(s)*$/, function (maxof, number, withS) {
|
|
360
356
|
var waitTime = number * 1000;
|
|
361
357
|
if (maxof) {
|
|
@@ -365,19 +361,73 @@ When(/^I wait( max of)* (\d*) second(s)*$/, function (maxof, number, withS) {
|
|
|
365
361
|
});
|
|
366
362
|
|
|
367
363
|
/**
|
|
368
|
-
* Wait a specific number of minutes, or a max number of minutes
|
|
369
|
-
|
|
370
|
-
* Example: When I wait
|
|
371
|
-
* Example: When I wait
|
|
372
|
-
*
|
|
373
|
-
*
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
*/
|
|
364
|
+
* Wait a specific number of minutes, or a max number of minutes until the element present.
|
|
365
|
+
* Example: When I wait 1 minute
|
|
366
|
+
* Example: When I wait 5 minutes
|
|
367
|
+
* Example: When I wait max of 6 minutes
|
|
368
|
+
*
|
|
369
|
+
* @When /^I wait( max of)* "([^"]*)?" minute(s)*$/
|
|
370
|
+
*
|
|
371
|
+
*/
|
|
377
372
|
When(/^I wait( max of)* (\d*) minute(s)*$/, function (maxof, number, withS) {
|
|
378
373
|
var waitTime = number * 60 * 1000;
|
|
379
374
|
if (maxof) {
|
|
380
375
|
return browser.waitForElementPresent('body', waitTime);
|
|
381
376
|
}
|
|
382
377
|
return browser.pause(waitTime);
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Checks, that the current page response status is equal or not equal to the specified code
|
|
382
|
+
* Example: Then the response status code should be 200
|
|
383
|
+
* Example: And the response status code should not be 404
|
|
384
|
+
*
|
|
385
|
+
* @Then /^the response status code should( not)* be (?P<code>\d+)$/
|
|
386
|
+
*/
|
|
387
|
+
Then(/^the response status code should( not)* be (\d+)$/, function (negativeCase, expectedStatusCode) {
|
|
388
|
+
|
|
389
|
+
browser.url(function (currentURL) {
|
|
390
|
+
request(currentURL.value, (error, response, body) => {
|
|
391
|
+
if (negativeCase) {
|
|
392
|
+
return browser.assert.not.equal(response.statusCode, expectedStatusCode).end();
|
|
393
|
+
}
|
|
394
|
+
return browser.assert.equal(response.statusCode, expectedStatusCode).end();
|
|
395
|
+
|
|
396
|
+
});
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Checks, that page contains text matching specified pattern
|
|
402
|
+
* Example: Then I should see text matching "^T\w+" //pattern of word start with 'T'
|
|
403
|
+
*
|
|
404
|
+
* @Then /^I should see( not)* text matching "([^"]*)?" in the "([^"]*)?" element$/
|
|
405
|
+
*/
|
|
406
|
+
Then(/^I should( not)* see text matching "([^"]*)?"$/, function (negativeCase, textPattern) {
|
|
407
|
+
// return browser.assert.smartTextMatching(negativeCase, textPattern);
|
|
408
|
+
browser.elements('css selector', 'body', function (elements) {
|
|
409
|
+
elements.value.forEach(function (elementsObj) {
|
|
410
|
+
if (negativeCase) {
|
|
411
|
+
return browser.assert.not.textMatches(elementsObj, textPattern);
|
|
412
|
+
}
|
|
413
|
+
return browser.assert.textMatches(elementsObj, textPattern);
|
|
414
|
+
});
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Checks, that page contains text matching specified pattern
|
|
420
|
+
* Example: Then I should see text matching "(0?[1-9]|[12][0-9]|3[01])[\/\-](0?[1-9]|1[012])[\/\-]\d{4}" in the "#date" element //pattern of DD/MM/YYYY or DD-MM-YYYY
|
|
421
|
+
*
|
|
422
|
+
* @Then /^I should see( not)* text matching "([^"]*)?" in the "([^"]*)?" element$/
|
|
423
|
+
*/
|
|
424
|
+
Then(/^I should( not)* see text matching "([^"]*)?" in the "([^"]*)?" element$/, function (negativeCase, textPattern, element) {
|
|
425
|
+
browser.elements('css selector', element, function (elements) {
|
|
426
|
+
elements.value.forEach(function (elementsObj) {
|
|
427
|
+
if (negativeCase) {
|
|
428
|
+
return browser.assert.not.textMatches(elementsObj, textPattern);
|
|
429
|
+
}
|
|
430
|
+
return browser.assert.textMatches(elementsObj, textPattern);
|
|
431
|
+
});
|
|
432
|
+
});
|
|
383
433
|
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# Template NodeJS build
|
|
2
|
-
|
|
3
|
-
# This template allows you to validate your NodeJS code.
|
|
4
|
-
# The workflow allows running tests and code linting on the default branch.
|
|
5
|
-
|
|
6
|
-
image: node:16
|
|
7
|
-
|
|
8
|
-
pipelines:
|
|
9
|
-
default:
|
|
10
|
-
- parallel:
|
|
11
|
-
- step:
|
|
12
|
-
name: selenium linting
|
|
13
|
-
script:
|
|
14
|
-
- pull selenium/hub:latest
|
|
15
|
-
- pull selenium/standalone-chrome
|
|
16
|
-
- run java -jar selenium-server-standalone-3.141.59.jar -port 4444
|
|
17
|
-
services:
|
|
18
|
-
- docker
|
|
19
|
-
caches:
|
|
20
|
-
- node
|
|
21
|
-
- step:
|
|
22
|
-
name: Build and Test
|
|
23
|
-
caches:
|
|
24
|
-
- node
|
|
25
|
-
script:
|
|
26
|
-
- npm install
|
|
27
|
-
- npm test
|
|
28
|
-
- step:
|
|
29
|
-
name: Code linting
|
|
30
|
-
script:
|
|
31
|
-
- npm install eslint
|
|
32
|
-
- npx eslint .
|
|
33
|
-
caches:
|
|
34
|
-
- node
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
Feature: Example test for I should see text matching "some text"
|
|
2
|
-
As a tester
|
|
3
|
-
I want to be able to text matching in a page
|
|
4
|
-
|
|
5
|
-
Scenario: Check I should see text matching "some text"
|
|
6
|
-
Given I am on the homepage
|
|
7
|
-
When I go to "about-us.html"
|
|
8
|
-
Then I should see text matching "About Us"
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
|