webship-js 1.0.19 → 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 +2 -2
- package/examples/test--then--i-should--see-text-matching-pattern.html +31 -0
- package/examples/{test--when--i-follow-link.html → test--when--i-click-link.html} +3 -3
- 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/smartClickLink.js +23 -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 +16 -0
- 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 +161 -111
- package/bitbucket-pipelines-test.yml +0 -34
- package/lib/custom-commands/smartLinkFollow.js +0 -17
- 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-follow-link.feature +0 -13
- 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
|
@@ -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.
|
|
@@ -82,7 +91,7 @@ When(/^I move backward one page$/, function () {
|
|
|
82
91
|
});
|
|
83
92
|
|
|
84
93
|
/**
|
|
85
|
-
* Presses button with specified id|class|name|
|
|
94
|
+
* Presses button with specified id|class|name|value
|
|
86
95
|
* Example: When I press "Log In"
|
|
87
96
|
* Example: And I press "Log In"
|
|
88
97
|
*
|
|
@@ -94,14 +103,14 @@ When(/^I press "([^"]*)?"$/, function (elementValue) {
|
|
|
94
103
|
});
|
|
95
104
|
|
|
96
105
|
/**
|
|
97
|
-
* Clicks link with specified id|class|name|
|
|
98
|
-
* Example: When I
|
|
99
|
-
* Example: And I
|
|
106
|
+
* Clicks link with specified id|class|name|text
|
|
107
|
+
* Example: When I click "Contact Us"
|
|
108
|
+
* Example: And I click "aboutUs"
|
|
100
109
|
*
|
|
101
|
-
* @When /^I
|
|
110
|
+
* @When /^I click "([^"]*)?"$/
|
|
102
111
|
*/
|
|
103
|
-
When(/^I
|
|
104
|
-
browser.
|
|
112
|
+
When(/^I click "([^"]*)?"$/, function (item) {
|
|
113
|
+
browser.smartClickLink(item);
|
|
105
114
|
});
|
|
106
115
|
|
|
107
116
|
/**
|
|
@@ -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,17 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
module.exports.command = function (item) {
|
|
3
|
-
|
|
4
|
-
browser.element('css selector', item, function (result) {
|
|
5
|
-
if (result.status === 0) {
|
|
6
|
-
return browser.click("link text", result.value);
|
|
7
|
-
} else {
|
|
8
|
-
browser.element('css selector', '#' + item, function (result) {
|
|
9
|
-
if (result.status === 0) {
|
|
10
|
-
return browser.click("link text", result.value);
|
|
11
|
-
} else {
|
|
12
|
-
return browser.click("link text", item);
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
}
|
|
@@ -1,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 follow 'link'"
|
|
2
|
-
|
|
3
|
-
As a tester
|
|
4
|
-
I want to be able to test when a link is clicked,
|
|
5
|
-
it will go to the link path page
|
|
6
|
-
|
|
7
|
-
Scenario: Check the "When I follow link" step definitions
|
|
8
|
-
Given I am on "test--when--i-follow-link.html"
|
|
9
|
-
When I follow "About us link"
|
|
10
|
-
Then I should see "About Us"
|
|
11
|
-
When I move backward one page
|
|
12
|
-
And I follow "aboutUs"
|
|
13
|
-
Then I should see "About Us"
|
|
@@ -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
|
-
|