webship-js 1.0.20 → 1.0.23
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 +10 -7
- package/.github/workflows/github-actions.yml +7 -4
- package/.gitlab-ci.yml +23 -35
- package/CNAME +1 -0
- 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--not--see-text-in-element.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/examples/test-acceptable-url-path.html +11 -0
- package/generate-reports.js +1 -1
- package/lib/custom-assertions/backToHomepage.js +15 -0
- package/lib/custom-assertions/{smartCheckboxChecked.js → checkboxChecked.js} +10 -10
- package/lib/custom-assertions/{smartElementContainsCss.js → elementContainsCss.js} +10 -10
- package/lib/custom-assertions/{smartElementContains.js → elementContainsText.js} +10 -10
- package/lib/custom-assertions/responseStatus.js +13 -0
- package/lib/custom-assertions/shouldVisible.js +8 -0
- package/lib/custom-assertions/textMatching.js +12 -0
- package/lib/custom-commands/{smartUploadFile.js → fileUpload.js} +0 -1
- package/lib/custom-commands/press.js +3 -0
- package/lib/custom-commands/{smartSelectOption.js → selectOption.js} +8 -8
- package/lib/custom-commands/wait.js +12 -0
- package/nightwatch.conf.js +2 -2
- package/package.json +5 -6
- package/tests/features/test--given--i-am-on-homepage.feature +11 -7
- package/tests/features/test--then--i-should--not--see-text-in-element.feature +12 -8
- 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 +7 -7
- 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--then--the-url-should-match.feature +7 -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 +180 -189
- package/bitbucket-pipelines-test.yml +0 -34
- package/lib/custom-commands/smartPressButton.js +0 -12
- 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/lib/custom-commands/{smartCheckItem.js → checkItem.js} +0 -0
- /package/lib/custom-commands/{smartClickLink.js → clickLink.js} +0 -0
- /package/lib/custom-commands/{smartFillTextInput.js → fillTextInput.js} +0 -0
- /package/lib/custom-commands/{smartUncheckItem.js → uncheckItem.js} +0 -0
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
const { Given } = require('@cucumber/cucumber');
|
|
2
2
|
const { When, Before } = require('@cucumber/cucumber');
|
|
3
3
|
const { Then } = require('@cucumber/cucumber');
|
|
4
|
+
const { endsWith } = require('lodash');
|
|
5
|
+
|
|
6
|
+
const request = require('request');
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* Opens homepage.
|
|
7
10
|
* Example: Given I am on homepage
|
|
8
11
|
* Example: Given I am on the homepage
|
|
9
12
|
*
|
|
10
|
-
* @Given /^I am on( the)* homepage$/
|
|
11
13
|
*/
|
|
12
|
-
Given(/^I am on( the)* homepage$/, function (
|
|
14
|
+
Given(/^(I am|we are) on( the)* homepage$/, function (pronoundCase, theCase) {
|
|
13
15
|
return browser.url(browser.launch_url);
|
|
14
16
|
});
|
|
15
17
|
|
|
@@ -17,9 +19,8 @@ Given(/^I am on( the)* homepage$/, function (url) {
|
|
|
17
19
|
* Open specific page
|
|
18
20
|
* Example: Given I am on "about-us.html"
|
|
19
21
|
*
|
|
20
|
-
* @Given /^I am on "([^"]*)?"$/
|
|
21
22
|
*/
|
|
22
|
-
Given(/^I am on "([^"]*)?"$/, function (url) {
|
|
23
|
+
Given(/^(I am|we are) on "([^"]*)?"$/, function (pronoundCase, url) {
|
|
23
24
|
return browser.url(browser.launch_url + url);
|
|
24
25
|
});
|
|
25
26
|
|
|
@@ -28,9 +29,8 @@ Given(/^I am on "([^"]*)?"$/, function (url) {
|
|
|
28
29
|
* Example: When I go to the homepage
|
|
29
30
|
* Example: And I go to "/"
|
|
30
31
|
*
|
|
31
|
-
* @When /^I go to( the)* homepage$/
|
|
32
32
|
*/
|
|
33
|
-
When(/^I go to( the)* homepage$/, function () {
|
|
33
|
+
When(/^(I|we)* go to( the)* homepage$/, function (pronoundCase, theCase) {
|
|
34
34
|
return browser.url(browser.launch_url);
|
|
35
35
|
});
|
|
36
36
|
|
|
@@ -38,9 +38,8 @@ When(/^I go to( the)* homepage$/, function () {
|
|
|
38
38
|
* Go to specific page
|
|
39
39
|
* Example: When I go to "contact-us.html"
|
|
40
40
|
*
|
|
41
|
-
* @When /^I go to "([^"]*)?"$/
|
|
42
41
|
*/
|
|
43
|
-
When(/^I go to "([^"]*)?"$/, function (url) {
|
|
42
|
+
When(/^(I|we)* go to "([^"]*)?"$/, function (pronoundCase, url) {
|
|
44
43
|
return browser.url(browser.launch_url + url);
|
|
45
44
|
});
|
|
46
45
|
|
|
@@ -51,23 +50,17 @@ When(/^I go to "([^"]*)?"$/, function (url) {
|
|
|
51
50
|
* - Then I should see "Welcome"
|
|
52
51
|
* - Then I should not see "Access denied"
|
|
53
52
|
*
|
|
54
|
-
* @Then /^I should( not)* see "([^"]*)?"$/
|
|
55
53
|
*/
|
|
56
|
-
Then(/^I should( not)* see "([^"]*)?"$/, function (negativeCase, expectedText) {
|
|
57
|
-
|
|
58
|
-
return browser.assert.not.textContains('html', expectedText);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return browser.assert.textContains('html', expectedText);
|
|
54
|
+
Then(/^(I|we)* should( not)* see "([^"]*)?"$/, function (pronoundCase, negativeCase, expectedText) {
|
|
55
|
+
return browser.assert.elementContainsText(negativeCase, expectedText, "html");
|
|
62
56
|
});
|
|
63
57
|
|
|
64
58
|
/**
|
|
65
59
|
* Moves forward one page in history
|
|
66
60
|
* Example: When I move forward one page
|
|
67
61
|
*
|
|
68
|
-
* @When /^I move forward one page$/
|
|
69
62
|
*/
|
|
70
|
-
When(/^I move forward one page$/, function () {
|
|
63
|
+
When(/^(I|we)* move forward one page$/, function (pronoundCase) {
|
|
71
64
|
return browser.forward();
|
|
72
65
|
});
|
|
73
66
|
|
|
@@ -75,9 +68,8 @@ When(/^I move forward one page$/, function () {
|
|
|
75
68
|
* Moves backward one page in history
|
|
76
69
|
* Example: When I move backward one page
|
|
77
70
|
*
|
|
78
|
-
* @When /^I move backward one page$/
|
|
79
71
|
*/
|
|
80
|
-
When(/^I move backward one page$/, function () {
|
|
72
|
+
When(/^(I|we)* move backward one page$/, function (pronoundCase) {
|
|
81
73
|
return browser.back();
|
|
82
74
|
});
|
|
83
75
|
|
|
@@ -86,11 +78,9 @@ When(/^I move backward one page$/, function () {
|
|
|
86
78
|
* Example: When I press "Log In"
|
|
87
79
|
* Example: And I press "Log In"
|
|
88
80
|
*
|
|
89
|
-
* @When /^I press "([^"]*)?"$/
|
|
90
81
|
*/
|
|
91
|
-
When(/^I press "([^"]*)?"$/, function (elementValue) {
|
|
92
|
-
return browser.
|
|
93
|
-
// return browser.smartPressButton(elementValue);
|
|
82
|
+
When(/^(I|we)* press "([^"]*)?"$/, function (pronoundCase, elementValue) {
|
|
83
|
+
return browser.press(elementValue);
|
|
94
84
|
});
|
|
95
85
|
|
|
96
86
|
/**
|
|
@@ -98,10 +88,9 @@ When(/^I press "([^"]*)?"$/, function (elementValue) {
|
|
|
98
88
|
* Example: When I click "Contact Us"
|
|
99
89
|
* Example: And I click "aboutUs"
|
|
100
90
|
*
|
|
101
|
-
* @When /^I click "([^"]*)?"$/
|
|
102
91
|
*/
|
|
103
|
-
When(/^I click "([^"]*)?"$/, function (item) {
|
|
104
|
-
browser.
|
|
92
|
+
When(/^(I|we)* click "([^"]*)?"$/, function (pronoundCase, item) {
|
|
93
|
+
browser.clickLink(item);
|
|
105
94
|
});
|
|
106
95
|
|
|
107
96
|
/**
|
|
@@ -109,9 +98,8 @@ When(/^I click "([^"]*)?"$/, function (item) {
|
|
|
109
98
|
* Example: When I reload the page
|
|
110
99
|
* Example: And I reload the page
|
|
111
100
|
*
|
|
112
|
-
* @When /^I reload( the)* page$/
|
|
113
101
|
*/
|
|
114
|
-
When(/^I reload( the)* page$/, function (
|
|
102
|
+
When(/^(I|we)* reload( the)* page$/, function (pronoundCase, theCase) {
|
|
115
103
|
return browser.refresh(browser.getCurrentUrl());
|
|
116
104
|
});
|
|
117
105
|
|
|
@@ -119,30 +107,27 @@ When(/^I reload( the)* page$/, function (url) {
|
|
|
119
107
|
* Define the step of filling values in the form field specified by id|class|name|label.
|
|
120
108
|
* Example: When I fill in "Username" with "John Smith"
|
|
121
109
|
*
|
|
122
|
-
* @When /^I fill in "([^"]*)?" with "([^"]*)?"$/
|
|
123
110
|
*/
|
|
124
|
-
When(/^I fill in "([^"]*)?" with "([^"]*)?"$/, function (field, value) {
|
|
125
|
-
browser.
|
|
111
|
+
When(/^(I|we)* fill in "([^"]*)?" with "([^"]*)?"$/, function (pronoundCase, field, value) {
|
|
112
|
+
browser.fillTextInput(field, value);
|
|
126
113
|
});
|
|
127
114
|
|
|
128
115
|
/**
|
|
129
116
|
* Fills in form field with specified id|class|name|label
|
|
130
117
|
* Example: When I fill in "username" with:
|
|
131
118
|
*
|
|
132
|
-
* @When /^I fill in "([^"]*)?" with:$/
|
|
133
119
|
*/
|
|
134
|
-
When(/^I fill in "([^"]*)?" with:$/, function (field) {
|
|
135
|
-
browser.
|
|
120
|
+
When(/^(I|we)* fill in "([^"]*)?" with:$/, function (pronoundCase, field) {
|
|
121
|
+
browser.fillTextInput(field, '');
|
|
136
122
|
});
|
|
137
123
|
|
|
138
124
|
/**
|
|
139
125
|
* Fills in form field with specified id|class|name|label
|
|
140
126
|
* Example: And I fill in "webshipco" for "username"
|
|
141
127
|
*
|
|
142
|
-
* @When /^I fill in "([^"]*)?" for "([^"]*)?"$/
|
|
143
128
|
*/
|
|
144
|
-
When(/^I fill in "([^"]*)?" for "([^"]*)?"$/, function (value, field) {
|
|
145
|
-
browser.
|
|
129
|
+
When(/^(I|we)* fill in "([^"]*)?" for "([^"]*)?"$/, function (pronoundCase, value, field) {
|
|
130
|
+
browser.fillTextInput(field, value);
|
|
146
131
|
});
|
|
147
132
|
|
|
148
133
|
/**
|
|
@@ -154,13 +139,12 @@ When(/^I fill in "([^"]*)?" for "([^"]*)?"$/, function (value, field) {
|
|
|
154
139
|
* | username | webshipco |
|
|
155
140
|
* | password | 1234 |
|
|
156
141
|
*
|
|
157
|
-
* @When /^I fill in the following:$/
|
|
158
142
|
*/
|
|
159
|
-
When(/^I fill in the following:$/, function (table) {
|
|
143
|
+
When(/^(I|we)* fill in the following:$/, function (pronoundCase, table) {
|
|
160
144
|
|
|
161
|
-
browser.
|
|
145
|
+
browser.fillTextInput(table.rawTable[0][0], table.rawTable[0][1]);
|
|
162
146
|
table.rows().forEach(row => {
|
|
163
|
-
browser.
|
|
147
|
+
browser.fillTextInput(row[0], row[1]);
|
|
164
148
|
});
|
|
165
149
|
});
|
|
166
150
|
|
|
@@ -168,216 +152,223 @@ When(/^I fill in the following:$/, function (table) {
|
|
|
168
152
|
* Selects option in select field with specified id|class|name|label
|
|
169
153
|
* Example: When I select "mercedes" from "Cars"
|
|
170
154
|
*
|
|
171
|
-
* @When /^I select "([^"]*)?" from "([^"]*)?"$/
|
|
172
155
|
*/
|
|
173
|
-
When(/^I select "([^"]*)?" from "([^"]*)?"$/, function (option,
|
|
174
|
-
browser.
|
|
156
|
+
When(/^(I|we)* select "([^"]*)?" from "([^"]*)?"$/, function (pronoundCase, option, dropdownlist) {
|
|
157
|
+
browser.selectOption(option, dropdownlist);
|
|
175
158
|
});
|
|
176
159
|
|
|
177
160
|
/**
|
|
178
|
-
* Checks checkbox specified by id|class|name|label
|
|
179
|
-
* Example: When I check "Remember me"
|
|
180
|
-
*
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
browser.smartCheckItem(item);
|
|
161
|
+
* Checks checkbox specified by id|class|name|label
|
|
162
|
+
* Example: When I check "Remember me"
|
|
163
|
+
*
|
|
164
|
+
*/
|
|
165
|
+
When(/^(I|we)* check "([^"]*)?"$/, function (pronoundCase, item) {
|
|
166
|
+
browser.checkItem(item);
|
|
185
167
|
});
|
|
186
168
|
|
|
187
169
|
/**
|
|
188
|
-
* Unchecks checkbox specified by id|class|name|label
|
|
189
|
-
* Example: When I uncheck "Remember me"
|
|
190
|
-
*
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
browser.smartUncheckItem(item);
|
|
170
|
+
* Unchecks checkbox specified by id|class|name|label
|
|
171
|
+
* Example: When I uncheck "Remember me"
|
|
172
|
+
*
|
|
173
|
+
*/
|
|
174
|
+
When(/^(I|we)* uncheck "([^"]*)?"$/, function (pronoundCase, item) {
|
|
175
|
+
browser.uncheckItem(item);
|
|
195
176
|
});
|
|
196
177
|
|
|
197
178
|
/**
|
|
198
|
-
* Verify, that current page is the homepage
|
|
199
|
-
* Example: Then I should be on the homepage
|
|
200
|
-
*
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
return browser.assert.urlEquals(browser.launch_url);
|
|
179
|
+
* Verify, that current page is the homepage
|
|
180
|
+
* Example: Then I should be on the homepage
|
|
181
|
+
*
|
|
182
|
+
*/
|
|
183
|
+
Then(/^(I|we)* should( not)* be on( the)* homepage$/, function (pronoundCase, negativeCase, theCase) {
|
|
184
|
+
return browser.assert.backToHomepage(negativeCase);
|
|
205
185
|
});
|
|
206
186
|
|
|
207
187
|
/**
|
|
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
|
-
|
|
214
|
-
|
|
215
|
-
Then(/^I should be on "([^"]*)?"$/, function (url) {
|
|
188
|
+
* Verify, that current page path is equal to specified
|
|
189
|
+
* Example: Then I should be on "/"
|
|
190
|
+
* Example: And I should be on "/user/login"
|
|
191
|
+
* Example: And I should be on "http://google.com"
|
|
192
|
+
*
|
|
193
|
+
*/
|
|
194
|
+
Then(/^(I|we)* should be on "([^"]*)?"$/, function (pronoundCase, url) {
|
|
216
195
|
return browser.assert.urlContains(url);
|
|
217
196
|
});
|
|
218
197
|
|
|
219
198
|
/**
|
|
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
|
-
|
|
225
|
-
*/
|
|
199
|
+
* Checks, that HTML response contains specific text specified by id|class|name|label
|
|
200
|
+
* Example: Then the response should contain "Welcome visitor, How can I help you?"
|
|
201
|
+
* Example: Then the response should not contain "Error: Ambiguous messages that are unclear"
|
|
202
|
+
*
|
|
203
|
+
*/
|
|
226
204
|
Then(/^the response should( not)* contain "([^"]*)?"$/, function (negativeCase, expectedText) {
|
|
227
|
-
|
|
228
|
-
return browser.assert.not.textContains('html', expectedText);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
return browser.assert.textContains('html', expectedText);
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
/**
|
|
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
|
-
*/
|
|
241
|
-
Then(/^I should( not)* see "([^"]*)?" in the "([^"]*)?" element$/, function (negativeCase, expectedText, element) {
|
|
242
|
-
return browser.assert.smartElementContains(negativeCase, expectedText, element);
|
|
205
|
+
return browser.assert.elementContainsText(negativeCase, expectedText, 'html');
|
|
243
206
|
});
|
|
244
207
|
|
|
245
208
|
/**
|
|
246
|
-
* Assert, that
|
|
247
|
-
* Example: Then I should see
|
|
248
|
-
* Example: Then I should
|
|
249
|
-
*
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
if (negativeCase) {
|
|
254
|
-
return browser.assert.not.textContains('html', expectedText);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
return browser.assert.textContains('html', expectedText);
|
|
209
|
+
* Assert, that element contains a specific text value specified by id|class|name|label
|
|
210
|
+
* Example: Then I should see "John Smith" in the "Username" element
|
|
211
|
+
* Example: Then I should see "Joe Smith" in the "Username" element
|
|
212
|
+
*
|
|
213
|
+
*/
|
|
214
|
+
Then(/^(I|we)* should( not)* see "([^"]*)?" in the "([^"]*)?" element$/, function (pronoundCase, negativeCase, expectedText, element) {
|
|
215
|
+
return browser.assert.elementContainsText(negativeCase, expectedText, element);
|
|
258
216
|
});
|
|
259
217
|
|
|
260
218
|
/**
|
|
261
219
|
* Assert, that element exists on page specified by id|class|name|label
|
|
262
220
|
* Example: Then I should see a "body" element
|
|
221
|
+
* Example: Then I should see an "Email" element
|
|
222
|
+
* Example: Then I should not see a "Username" element
|
|
223
|
+
* Example: Then I should not see an "img" element
|
|
263
224
|
*
|
|
264
|
-
* @Then /^I should( not)* see a(n)* "([^"]*)?" element$/
|
|
265
225
|
*/
|
|
266
|
-
Then(/^I should( not)* see a(n)* "([^"]*)?" element$/, function (negativeCase, identification, element) {
|
|
267
|
-
|
|
268
|
-
return browser.verify.not.visible(element);
|
|
269
|
-
}
|
|
270
|
-
return browser.verify.visible(element);
|
|
226
|
+
Then(/^(I|we)* should( not)* see a(n)* "([^"]*)?" element$/, function (pronoundCase, negativeCase, identification, element) {
|
|
227
|
+
return browser.assert.shouldVisible(negativeCase, element);
|
|
271
228
|
});
|
|
272
229
|
|
|
273
230
|
/**
|
|
274
231
|
* Assert, that element contains a specific CSS style specified by id|class|name|label|tag.
|
|
275
232
|
* Example: Then the "body" element should contain "color:white;"
|
|
276
233
|
*
|
|
277
|
-
* @Then /^the "([^"]*)?" element should( not)* contain "([^"]*)?"$/
|
|
278
234
|
*/
|
|
279
235
|
Then(/^the "([^"]*)?" element should( not)* contain "([^"]*)?"$/, function (element, negativeCase, elementCss) {
|
|
280
|
-
return browser.assert.
|
|
236
|
+
return browser.assert.elementContainsCss(element, negativeCase, elementCss);
|
|
281
237
|
});
|
|
282
238
|
|
|
283
239
|
/**
|
|
284
|
-
* Attaches file to field with specified id|class|name|label
|
|
285
|
-
* Example: When I attach the file "profileIcon.jpg" to "profileIconUpload"
|
|
286
|
-
*
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
browser.smartUploadFile(fileUrl, element);
|
|
240
|
+
* Attaches file to field with specified id|class|name|label
|
|
241
|
+
* Example: When I attach the file "profileIcon.jpg" to "profileIconUpload"
|
|
242
|
+
*
|
|
243
|
+
*/
|
|
244
|
+
When(/^(I|we)* attach the file "([^"]*)?" to "([^"]*)?"$/, function (pronoundCase, fileUrl, element) {
|
|
245
|
+
browser.fileUpload("../../../tests/assets/" + fileUrl, element);
|
|
291
246
|
});
|
|
292
247
|
|
|
293
248
|
/**
|
|
294
249
|
* Assert, that form field with specified id|class|name|label has specified value
|
|
295
250
|
* Example: Then the "username" field should contain "John Smith"
|
|
296
251
|
*
|
|
297
|
-
* @Then /^the "([^"]*)?" field should( not)* contain "([^"]*)?"$/
|
|
298
252
|
*/
|
|
299
253
|
Then(/^the "([^"]*)?" field should( not)* contain "([^"]*)?"$/, function (field, negativeCase, expectedText) {
|
|
300
|
-
return browser.assert.
|
|
254
|
+
return browser.assert.elementContainsText(negativeCase, expectedText, field);
|
|
301
255
|
});
|
|
302
256
|
|
|
303
257
|
/**
|
|
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
|
-
|
|
308
|
-
*
|
|
309
|
-
*/
|
|
258
|
+
* Assert, that checkbox with specified id|class|name|label is should be checked
|
|
259
|
+
* Example: Then the "PrivacyPolicy" checkbox should be checked
|
|
260
|
+
*
|
|
261
|
+
*/
|
|
310
262
|
Then(/^the "([^"]*)?" checkbox should( not)* be checked$/, function (checkbox, negativeCase) {
|
|
311
|
-
return browser.assert.
|
|
263
|
+
return browser.assert.checkboxChecked(checkbox, negativeCase);
|
|
312
264
|
});
|
|
313
265
|
|
|
314
266
|
/**
|
|
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
|
-
|
|
319
|
-
|
|
320
|
-
*/
|
|
267
|
+
* Check, whether the checkbox specified by id|class|name|label is checked or not.
|
|
268
|
+
* Example: Then the "Remember Me" checkbox is checked
|
|
269
|
+
*
|
|
270
|
+
*
|
|
271
|
+
*/
|
|
321
272
|
Then(/^the "([^"]*)?" checkbox is( not)* checked$/, function (checkbox, negativeCase) {
|
|
322
|
-
return browser.assert.
|
|
273
|
+
return browser.assert.checkboxChecked(checkbox, negativeCase);
|
|
323
274
|
});
|
|
324
275
|
|
|
325
276
|
/**
|
|
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
|
-
|
|
331
|
-
*
|
|
332
|
-
*/
|
|
277
|
+
* Assert, that checkbox with specified id|name|label|value is checked
|
|
278
|
+
* Example: Then the checkbox "PrivacyPolicy" should be checked
|
|
279
|
+
* Example: Then the checkbox "PrivacyPolicy" should not be checked
|
|
280
|
+
*
|
|
281
|
+
*/
|
|
333
282
|
Then(/^the checkbox "([^"]*)?" should( not)* be checked$/, function (checkbox, negativeCase) {
|
|
334
|
-
return browser.assert.
|
|
283
|
+
return browser.assert.checkboxChecked(checkbox, negativeCase);
|
|
335
284
|
});
|
|
336
285
|
|
|
337
286
|
/**
|
|
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
|
-
|
|
343
|
-
*
|
|
344
|
-
*/
|
|
287
|
+
* Assert, that checkbox with specified id|name|label|value is checked
|
|
288
|
+
* Example: Then the checkbox "Remember Me" is checked
|
|
289
|
+
* Example: And the checkbox "Remember Me" is not checked
|
|
290
|
+
*
|
|
291
|
+
*/
|
|
345
292
|
Then(/^the checkbox "([^"]*)?" is( not)* checked$/, function (checkbox, negativeCase) {
|
|
346
|
-
return browser.assert.
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
/**
|
|
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
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
*
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
*/
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
293
|
+
return browser.assert.checkboxChecked(checkbox, negativeCase);
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Wait a specific number of seconds, or a max number of seconds until the element present.
|
|
298
|
+
* Example: When I wait 1 second
|
|
299
|
+
* Example: When I wait 5 seconds
|
|
300
|
+
* Example: When I wait max of 6 seconds
|
|
301
|
+
*
|
|
302
|
+
*/
|
|
303
|
+
When(/^(I|we)* wait( max of)* (\d*) second(s)*$/, function (pronoundCase, maxof, number, withS) {
|
|
304
|
+
return browser.wait(maxof, number, "s");
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Wait a specific number of minutes, or a max number of minutes until the element present.
|
|
309
|
+
* Example: When I wait 1 minute
|
|
310
|
+
* Example: When I wait 5 minutes
|
|
311
|
+
* Example: When I wait max of 6 minutes
|
|
312
|
+
*
|
|
313
|
+
*/
|
|
314
|
+
When(/^(I|we)* wait( max of)* (\d*) minute(s)*$/, function (pronoundCase, maxof, number, withS) {
|
|
315
|
+
return browser.wait(maxof, number, "m");
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Checks, that the current page response status is equal or not equal to the specified code
|
|
320
|
+
* Example: Then the response status code should be 200
|
|
321
|
+
* Example: And the response status code should not be 404
|
|
322
|
+
*
|
|
323
|
+
*/
|
|
324
|
+
Then(/^the response status code should( not)* be (\d+)$/, function (negativeCase, expectedStatusCode) {
|
|
325
|
+
return browser.assert.responseStatus(negativeCase, expectedStatusCode);
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Checks, that page contains text matching specified pattern
|
|
330
|
+
* Example: Then I should see text matching "^T\w+" //pattern of word start with 'T'
|
|
331
|
+
*
|
|
332
|
+
*/
|
|
333
|
+
Then(/^(I|we)* should( not)* see text matching "([^"]*)?"$/, function (pronoundCase, negativeCase, textPattern) {
|
|
334
|
+
// return browser.assert.textMatching(negativeCase, textPattern);
|
|
335
|
+
browser.elements('css selector', 'body', function (elements) {
|
|
336
|
+
elements.value.forEach(function (elementsObj) {
|
|
337
|
+
if (negativeCase) {
|
|
338
|
+
return browser.assert.not.textMatches(elementsObj, textPattern);
|
|
339
|
+
}
|
|
340
|
+
return browser.assert.textMatches(elementsObj, textPattern);
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Checks, that page contains text matching specified pattern
|
|
347
|
+
* 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
|
|
348
|
+
*
|
|
349
|
+
*/
|
|
350
|
+
Then(/^(I|we)* should( not)* see text matching "([^"]*)?" in the "([^"]*)?" element$/, function (pronoundCase, negativeCase, textPattern, element) {
|
|
351
|
+
browser.elements('css selector', element, function (elements) {
|
|
352
|
+
elements.value.forEach(function (elementsObj) {
|
|
353
|
+
if (negativeCase) {
|
|
354
|
+
return browser.assert.not.textMatches(elementsObj, textPattern);
|
|
355
|
+
}
|
|
356
|
+
return browser.assert.textMatches(elementsObj, textPattern);
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Checks, that current URL Path matches regular expression
|
|
364
|
+
* Example: Then the url should match "/contact-us.html"
|
|
365
|
+
*
|
|
366
|
+
*/
|
|
367
|
+
Then(/^the url should( not)* match "([^"]*)?"$/, function (negativeCase, pattern) {
|
|
368
|
+
|
|
369
|
+
if (negativeCase) {
|
|
370
|
+
return browser.assert.not.urlMatches(pattern);
|
|
381
371
|
}
|
|
382
|
-
return browser.
|
|
372
|
+
return browser.assert.urlMatches(pattern);
|
|
373
|
+
|
|
383
374
|
});
|
|
@@ -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,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
|
-
return browser.click("[value='" + elementValue + "']");
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
}
|
|
@@ -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
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|