@qavajs/cypress 1.0.0 → 2.0.1
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/CHANGELOG.md +6 -0
- package/README.md +2 -3
- package/lib/actions.js +41 -61
- package/lib/execute.js +13 -15
- package/lib/memory.js +119 -47
- package/lib/memoryValue.js +26 -0
- package/lib/mouseActions.js +9 -9
- package/lib/pageObjects.js +92 -0
- package/lib/setup.js +7 -8
- package/lib/storage.js +14 -12
- package/lib/types.js +36 -8
- package/lib/utils.js +2 -19
- package/lib/validation.js +84 -93
- package/lib/valueValidation.js +66 -43
- package/package.json +4 -5
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
|
|
|
10
10
|
:pencil: - chore
|
|
11
11
|
:microscope: - experimental
|
|
12
12
|
|
|
13
|
+
## [2.0.1]
|
|
14
|
+
- :beetle: fixed issue with getting child element
|
|
15
|
+
|
|
16
|
+
## [2.0.0]
|
|
17
|
+
- :rocket: implemented new page object approach
|
|
18
|
+
|
|
13
19
|
## [0.2.0]
|
|
14
20
|
- :rocket: added memory write logs support
|
|
15
21
|
|
package/README.md
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
# @qavajs/cypress
|
|
2
|
-
qavajs implementation
|
|
2
|
+
qavajs implementation for cypress runner
|
|
3
3
|
|
|
4
4
|
## Installation
|
|
5
5
|
|
|
6
|
-
`npm install @qavajs/cypress`
|
|
7
|
-
`npm install @qavajs/cypress-runner-adapter`
|
|
6
|
+
`npm install @qavajs/cypress @qavajs/cypress-runner-adapter @qavajs/memory`
|
|
8
7
|
|
|
9
8
|
## Configuration
|
|
10
9
|
cypress.config.js
|
package/lib/actions.js
CHANGED
|
@@ -6,9 +6,8 @@ import { parseCoords } from './utils';
|
|
|
6
6
|
* @param {string} url - url to navigate
|
|
7
7
|
* @example I open 'https://google.com'
|
|
8
8
|
*/
|
|
9
|
-
When('I open {
|
|
10
|
-
|
|
11
|
-
cy.visit(urlValue);
|
|
9
|
+
When('I open {value} url', function (url) {
|
|
10
|
+
cy.visit(url.value());
|
|
12
11
|
});
|
|
13
12
|
|
|
14
13
|
/**
|
|
@@ -17,10 +16,8 @@ When('I open {string} url', function (url) {
|
|
|
17
16
|
* @param {string} value - value to type
|
|
18
17
|
* @example I type 'wikipedia' to 'Google Input'
|
|
19
18
|
*/
|
|
20
|
-
When('I type {
|
|
21
|
-
|
|
22
|
-
const typeValue = this.value(value);
|
|
23
|
-
element.type(typeValue);
|
|
19
|
+
When('I type {value} to {locator}', function (type, locator) {
|
|
20
|
+
locator.type(type.value());
|
|
24
21
|
});
|
|
25
22
|
//
|
|
26
23
|
/**
|
|
@@ -28,9 +25,8 @@ When('I type {string} to {string}', function (value, alias) {
|
|
|
28
25
|
* @param {string} alias - element to click
|
|
29
26
|
* @example I click 'Google Button'
|
|
30
27
|
*/
|
|
31
|
-
When('I click {
|
|
32
|
-
|
|
33
|
-
element.click();
|
|
28
|
+
When('I click {locator}', function (locator) {
|
|
29
|
+
locator.click();
|
|
34
30
|
});
|
|
35
31
|
|
|
36
32
|
/**
|
|
@@ -38,9 +34,8 @@ When('I click {string}', function (alias) {
|
|
|
38
34
|
* @param {string} alias - element to click
|
|
39
35
|
* @example I force click 'Google Button'
|
|
40
36
|
*/
|
|
41
|
-
When('I force click {
|
|
42
|
-
|
|
43
|
-
element.click({force: true});
|
|
37
|
+
When('I force click {locator}', function (locator) {
|
|
38
|
+
locator.click({force: true});
|
|
44
39
|
});
|
|
45
40
|
|
|
46
41
|
/**
|
|
@@ -48,9 +43,8 @@ When('I force click {string}', function (alias) {
|
|
|
48
43
|
* @param {string} alias - element to right click
|
|
49
44
|
* @example I right click 'Google Button'
|
|
50
45
|
*/
|
|
51
|
-
When('I right click {
|
|
52
|
-
|
|
53
|
-
element.rightclick();
|
|
46
|
+
When('I right click {locator}', function (locator) {
|
|
47
|
+
locator.rightclick();
|
|
54
48
|
});
|
|
55
49
|
|
|
56
50
|
/**
|
|
@@ -58,9 +52,8 @@ When('I right click {string}', function (alias) {
|
|
|
58
52
|
* @param {string} alias - double element to click
|
|
59
53
|
* @example I double click 'Google Button'
|
|
60
54
|
*/
|
|
61
|
-
When('I double click {
|
|
62
|
-
|
|
63
|
-
element.dblclick();
|
|
55
|
+
When('I double click {locator}', function (locator) {
|
|
56
|
+
locator.dblclick();
|
|
64
57
|
});
|
|
65
58
|
|
|
66
59
|
/**
|
|
@@ -68,9 +61,8 @@ When('I double click {string}', function (alias) {
|
|
|
68
61
|
* @param {string} alias - element to clear
|
|
69
62
|
* @example I clear 'Google Input'
|
|
70
63
|
*/
|
|
71
|
-
When('I clear {
|
|
72
|
-
|
|
73
|
-
element.clear();
|
|
64
|
+
When('I clear {locator}', function (locator) {
|
|
65
|
+
locator.clear();
|
|
74
66
|
});
|
|
75
67
|
|
|
76
68
|
/**
|
|
@@ -78,7 +70,7 @@ When('I clear {string}', function (alias) {
|
|
|
78
70
|
* @example I switch to parent frame
|
|
79
71
|
*/
|
|
80
72
|
When('I switch to parent frame', function () {
|
|
81
|
-
this.
|
|
73
|
+
this.cy = cy;
|
|
82
74
|
});
|
|
83
75
|
|
|
84
76
|
/**
|
|
@@ -87,9 +79,9 @@ When('I switch to parent frame', function () {
|
|
|
87
79
|
* @example I switch to 2 frame
|
|
88
80
|
*/
|
|
89
81
|
When('I switch to {int} frame', function (index) {
|
|
90
|
-
const root = this.
|
|
91
|
-
this.
|
|
92
|
-
.eq(
|
|
82
|
+
const root = this.cy === cy ? this.cy.get('iframe') : this.cy.find('iframe');
|
|
83
|
+
this.cy = root
|
|
84
|
+
.eq(index - 1)
|
|
93
85
|
.then((iframe) => iframe.contents())
|
|
94
86
|
.should('exist')
|
|
95
87
|
.find('body');
|
|
@@ -100,9 +92,8 @@ When('I switch to {int} frame', function (index) {
|
|
|
100
92
|
* @param {string} index - alias to switch
|
|
101
93
|
* @example I switch to 'IFrame' frame
|
|
102
94
|
*/
|
|
103
|
-
When('I switch to {
|
|
104
|
-
|
|
105
|
-
this.po.driver = frame
|
|
95
|
+
When('I switch to {locator} frame', function (frame) {
|
|
96
|
+
this.cy = frame
|
|
106
97
|
.then((iframe) => iframe.contents())
|
|
107
98
|
.should('exist')
|
|
108
99
|
.find('body');
|
|
@@ -144,11 +135,10 @@ When('I press {string} key(s) {int} time(s)', function (key, num) {
|
|
|
144
135
|
* @param {string} alias - element to hover over
|
|
145
136
|
* @example I hover over 'Google Button'
|
|
146
137
|
*/
|
|
147
|
-
When('I hover over {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
element.trigger('mousemove');
|
|
138
|
+
When('I hover over {locator}', function (locator) {
|
|
139
|
+
locator.trigger('mouseenter');
|
|
140
|
+
locator.trigger('mouseover');
|
|
141
|
+
locator.trigger('mousemove');
|
|
152
142
|
});
|
|
153
143
|
|
|
154
144
|
/**
|
|
@@ -158,10 +148,8 @@ When('I hover over {string}', function (alias) {
|
|
|
158
148
|
* @example I select '1900' option from 'Registration Form > Date Of Birth'
|
|
159
149
|
* @example I select '$dateOfBirth' option from 'Registration Form > Date Of Birth' dropdown
|
|
160
150
|
*/
|
|
161
|
-
When('I select {
|
|
162
|
-
|
|
163
|
-
const select = this.element(alias);
|
|
164
|
-
select.select(optionValue);
|
|
151
|
+
When('I select {value} option from {locator} dropdown', function (option, select) {
|
|
152
|
+
select.select(option.value());
|
|
165
153
|
});
|
|
166
154
|
|
|
167
155
|
/**
|
|
@@ -170,8 +158,7 @@ When('I select {string} option from {string} dropdown', function (option, alias)
|
|
|
170
158
|
* @param {string} alias - alias of select
|
|
171
159
|
* @example I select 1 option from 'Registration Form > Date Of Birth' dropdown
|
|
172
160
|
*/
|
|
173
|
-
When('I select {int}(st|nd|rd|th) option from {
|
|
174
|
-
const select = this.element(alias);
|
|
161
|
+
When('I select {int}(st|nd|rd|th) option from {locator} dropdown', function (optionIndex, select) {
|
|
175
162
|
select.select(optionIndex - 1);
|
|
176
163
|
});
|
|
177
164
|
//
|
|
@@ -183,11 +170,9 @@ When('I select {int}(st|nd|rd|th) option from {string} dropdown', function (opti
|
|
|
183
170
|
* @example I click '$someVarWithText' text in 'Search Engines' collection
|
|
184
171
|
*/
|
|
185
172
|
When(
|
|
186
|
-
'I click {
|
|
187
|
-
function (
|
|
188
|
-
|
|
189
|
-
const collection = this.element(alias);
|
|
190
|
-
collection.filter(`:contains(${resolvedValue})`).click();
|
|
173
|
+
'I click {value} text in {locator} collection',
|
|
174
|
+
function (text, collection) {
|
|
175
|
+
collection.filter(`:contains(${text.value()})`).click();
|
|
191
176
|
}
|
|
192
177
|
);
|
|
193
178
|
|
|
@@ -197,8 +182,8 @@ When(
|
|
|
197
182
|
* @example
|
|
198
183
|
* When I scroll by '0, 100'
|
|
199
184
|
*/
|
|
200
|
-
When('I scroll by {
|
|
201
|
-
const [x, y] = parseCoords(
|
|
185
|
+
When('I scroll by {value}', function (offset) {
|
|
186
|
+
const [x, y] = parseCoords(offset.value());
|
|
202
187
|
cy.scrollTo(x, y);
|
|
203
188
|
});
|
|
204
189
|
|
|
@@ -209,10 +194,9 @@ When('I scroll by {string}', function (offset) {
|
|
|
209
194
|
* @example
|
|
210
195
|
* When I scroll by '0, 100' in 'Overflow Container'
|
|
211
196
|
*/
|
|
212
|
-
When('I scroll by {
|
|
213
|
-
const [x, y] = parseCoords(
|
|
214
|
-
|
|
215
|
-
element.scrollTo(x, y);
|
|
197
|
+
When('I scroll by {value} in {locator}', function (offset, locator) {
|
|
198
|
+
const [x, y] = parseCoords(offset.value());
|
|
199
|
+
locator.scrollTo(x, y);
|
|
216
200
|
});
|
|
217
201
|
|
|
218
202
|
/**
|
|
@@ -221,9 +205,8 @@ When('I scroll by {string} in {string}', function (offset, alias) {
|
|
|
221
205
|
* @example
|
|
222
206
|
* When I scroll to 'Some Element'
|
|
223
207
|
*/
|
|
224
|
-
When('I scroll to {
|
|
225
|
-
|
|
226
|
-
element.scrollIntoView()
|
|
208
|
+
When('I scroll to {locator}', function (locator) {
|
|
209
|
+
locator.scrollIntoView()
|
|
227
210
|
});
|
|
228
211
|
|
|
229
212
|
|
|
@@ -233,10 +216,8 @@ When('I scroll to {string}', function (alias) {
|
|
|
233
216
|
* @param {string} value - file path
|
|
234
217
|
* @example I upload '/folder/file.txt' to 'File Input'
|
|
235
218
|
*/
|
|
236
|
-
When('I upload {
|
|
237
|
-
|
|
238
|
-
const filePath = this.value(value);
|
|
239
|
-
element.selectFile(filePath);
|
|
219
|
+
When('I upload {value} file to {locator}', function (filePath, locator) {
|
|
220
|
+
locator.selectFile(filePath.value());
|
|
240
221
|
});
|
|
241
222
|
|
|
242
223
|
/**
|
|
@@ -266,9 +247,8 @@ When('I will dismiss alert', function () {
|
|
|
266
247
|
* I will type {string} to alert
|
|
267
248
|
* @example I type 'coffee' to alert
|
|
268
249
|
*/
|
|
269
|
-
When('I will type {
|
|
270
|
-
const resolvedValue = this.value(value);
|
|
250
|
+
When('I will type {value} to alert', function (text) {
|
|
271
251
|
cy.window().then((win) => {
|
|
272
|
-
win.prompt = () =>
|
|
252
|
+
win.prompt = () => text.value();
|
|
273
253
|
});
|
|
274
254
|
});
|
package/lib/execute.js
CHANGED
|
@@ -6,8 +6,8 @@ import { When } from '@qavajs/cypress-runner-adapter';
|
|
|
6
6
|
* @example I execute '$fn' function // fn is function reference
|
|
7
7
|
* @example I execute 'window.scrollBy(0, 100)' function
|
|
8
8
|
*/
|
|
9
|
-
When('I execute {
|
|
10
|
-
const fnContent =
|
|
9
|
+
When('I execute {value} function', function (functionKey) {
|
|
10
|
+
const fnContent = functionKey.value();
|
|
11
11
|
const fn = typeof fnContent === 'string' ? new Function(`return ${fnContent}`): fnContent;
|
|
12
12
|
cy.window().then(win => {
|
|
13
13
|
fn.apply(win);
|
|
@@ -21,11 +21,11 @@ When('I execute {string} function', function (functionKey) {
|
|
|
21
21
|
* @example I execute '$fn' function and save result as 'result' // fn is function reference
|
|
22
22
|
* @example I execute 'window.scrollY' function and save result as 'scroll'
|
|
23
23
|
*/
|
|
24
|
-
When('I execute {
|
|
25
|
-
const fnContent =
|
|
24
|
+
When('I execute {value} function and save result as {value}', function (functionKey, memoryKey) {
|
|
25
|
+
const fnContent = functionKey.value();
|
|
26
26
|
const fn = typeof fnContent === 'string' ? new Function(`return ${fnContent}`): fnContent;
|
|
27
27
|
cy.window().then(win => {
|
|
28
|
-
|
|
28
|
+
memoryKey.set(fn.apply(win));
|
|
29
29
|
});
|
|
30
30
|
});
|
|
31
31
|
|
|
@@ -36,12 +36,11 @@ When('I execute {string} function and save result as {string}', function (functi
|
|
|
36
36
|
* @example I execute '$fn' function on 'Component > Element' // fn is function reference
|
|
37
37
|
* @example I execute 'arguments[0].scrollIntoView()' function on 'Component > Element'
|
|
38
38
|
*/
|
|
39
|
-
When('I execute {
|
|
40
|
-
const
|
|
41
|
-
const fnContent = this.value(functionKey);
|
|
39
|
+
When('I execute {value} function on {locator}', function (functionKey, locator) {
|
|
40
|
+
const fnContent = functionKey.value();
|
|
42
41
|
const fn = typeof fnContent === 'string' ? new Function(`return ${fnContent}`): fnContent;
|
|
43
42
|
cy.window().then(win => {
|
|
44
|
-
|
|
43
|
+
locator.then((e) => {
|
|
45
44
|
fn.apply(win, e);
|
|
46
45
|
});
|
|
47
46
|
});
|
|
@@ -55,14 +54,13 @@ When('I execute {string} function on {string}', function (functionKey, alias) {
|
|
|
55
54
|
* @example I execute 'arguments[0].innerText' function on 'Component > Element' and save result as 'innerText'
|
|
56
55
|
*/
|
|
57
56
|
When(
|
|
58
|
-
'I execute {
|
|
59
|
-
function (functionKey,
|
|
60
|
-
const
|
|
61
|
-
const fnContent = this.value(functionKey);
|
|
57
|
+
'I execute {value} function on {locator} and save result as {value}',
|
|
58
|
+
function (functionKey, locator, memoryKey) {
|
|
59
|
+
const fnContent = functionKey.value();
|
|
62
60
|
const fn = typeof fnContent === 'string' ? new Function(`return ${fnContent}`): fnContent;
|
|
63
61
|
cy.window().then(win => {
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
locator.then((e) => {
|
|
63
|
+
memoryKey.set(fn.apply(win, e));
|
|
66
64
|
});
|
|
67
65
|
});
|
|
68
66
|
}
|
package/lib/memory.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { When } from '@qavajs/cypress-runner-adapter';
|
|
2
|
+
import { dataTable2Object } from './utils';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Save text of element to memory
|
|
@@ -6,10 +7,9 @@ import { When } from '@qavajs/cypress-runner-adapter';
|
|
|
6
7
|
* @param {string} key - key to store value
|
|
7
8
|
* @example I save text of '#1 of Search Results' as 'firstSearchResult'
|
|
8
9
|
*/
|
|
9
|
-
When('I save text of {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
this.setValue(key, e.text());
|
|
10
|
+
When('I save text of {locator} as {value}', function (locator, key) {
|
|
11
|
+
locator.then(e => {
|
|
12
|
+
key.set(e.text());
|
|
13
13
|
});
|
|
14
14
|
});
|
|
15
15
|
|
|
@@ -21,11 +21,10 @@ When('I save text of {string} as {string}', function (alias, key) {
|
|
|
21
21
|
* @example I save 'checked' property of 'Checkbox' as 'checked'
|
|
22
22
|
* @example I save '$prop' property of 'Checkbox' as 'checked'
|
|
23
23
|
*/
|
|
24
|
-
When('I save {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.setValue(key, e.prop(propertyName));
|
|
24
|
+
When('I save {value} property of {locator} as {value}', function (property, locator, key) {
|
|
25
|
+
const propertyName = property.value();
|
|
26
|
+
locator.then((e) => {
|
|
27
|
+
key.set(e.prop(propertyName));
|
|
29
28
|
});
|
|
30
29
|
});
|
|
31
30
|
|
|
@@ -37,11 +36,10 @@ When('I save {string} property of {string} as {string}', function (property, ali
|
|
|
37
36
|
* @example I save 'href' attribute of 'Link' as 'linkHref'
|
|
38
37
|
* @example I save '$prop' attribute of 'Link' as 'linkHref'
|
|
39
38
|
*/
|
|
40
|
-
When('I save {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
this.setValue(key, e.attr(attributeName));
|
|
39
|
+
When('I save {value} attribute of {locator} as {value}', function (attribute, locator, key) {
|
|
40
|
+
const attributeName = attribute.value();
|
|
41
|
+
locator.then(e => {
|
|
42
|
+
key.set(e.attr(attributeName));
|
|
45
43
|
});
|
|
46
44
|
});
|
|
47
45
|
|
|
@@ -51,10 +49,9 @@ When('I save {string} attribute of {string} as {string}', function (attribute, a
|
|
|
51
49
|
* @param {string} key - key to store value
|
|
52
50
|
* @example I save number of elements in 'Search Results' as 'numberOfSearchResults'
|
|
53
51
|
*/
|
|
54
|
-
When('I save number of elements in {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this.setValue(key, c.length);
|
|
52
|
+
When('I save number of elements in {locator} collection as {value}', function (collection, key) {
|
|
53
|
+
collection.then(c => {
|
|
54
|
+
key.set(c.length);
|
|
58
55
|
});
|
|
59
56
|
});
|
|
60
57
|
|
|
@@ -65,15 +62,14 @@ When('I save number of elements in {string} collection as {string}', function (a
|
|
|
65
62
|
* @example I save text of every element of 'Search Results' collection as 'searchResults'
|
|
66
63
|
*/
|
|
67
64
|
When(
|
|
68
|
-
'I save text of every element of {
|
|
69
|
-
function (
|
|
70
|
-
const collection = this.element(alias);
|
|
65
|
+
'I save text of every element of {locator} collection as {value}',
|
|
66
|
+
function (collection, key) {
|
|
71
67
|
collection.then((c) => {
|
|
72
68
|
const values = [];
|
|
73
69
|
c.each(function () {
|
|
74
70
|
values.push(Cypress.$(this).text());
|
|
75
71
|
})
|
|
76
|
-
|
|
72
|
+
key.set(values);
|
|
77
73
|
});
|
|
78
74
|
}
|
|
79
75
|
);
|
|
@@ -85,15 +81,15 @@ When(
|
|
|
85
81
|
* @example I save 'checked' attribute of every element of 'Search > Checkboxes' collection as 'checkboxes'
|
|
86
82
|
*/
|
|
87
83
|
When(
|
|
88
|
-
'I save {
|
|
89
|
-
function (attribute,
|
|
90
|
-
const
|
|
84
|
+
'I save {value} attribute of every element of {locator} collection as {value}',
|
|
85
|
+
function (attribute, collection, key) {
|
|
86
|
+
const attributeName = attribute.value();
|
|
91
87
|
collection.then((c) => {
|
|
92
88
|
const values = [];
|
|
93
89
|
c.each(function () {
|
|
94
|
-
values.push(Cypress.$(this).attr(
|
|
90
|
+
values.push(Cypress.$(this).attr(attributeName));
|
|
95
91
|
})
|
|
96
|
-
|
|
92
|
+
key.set(values);
|
|
97
93
|
});
|
|
98
94
|
}
|
|
99
95
|
);
|
|
@@ -105,15 +101,15 @@ When(
|
|
|
105
101
|
* @example I save 'href' property of every element of 'Search > Links' collection as 'hrefs'
|
|
106
102
|
*/
|
|
107
103
|
When(
|
|
108
|
-
'I save {
|
|
109
|
-
function (property,
|
|
110
|
-
const
|
|
111
|
-
collection.then(
|
|
104
|
+
'I save {value} property of every element of {locator} collection as {value}',
|
|
105
|
+
function (property, collection, key) {
|
|
106
|
+
const propertyName = property.value();
|
|
107
|
+
collection.then(c => {
|
|
112
108
|
const values = [];
|
|
113
109
|
c.each(function () {
|
|
114
|
-
values.push(Cypress.$(this).prop(
|
|
110
|
+
values.push(Cypress.$(this).prop(propertyName));
|
|
115
111
|
})
|
|
116
|
-
|
|
112
|
+
key.set(values);
|
|
117
113
|
});
|
|
118
114
|
}
|
|
119
115
|
);
|
|
@@ -123,9 +119,9 @@ When(
|
|
|
123
119
|
* @param {string} key - key to store value
|
|
124
120
|
* @example I save current url as 'currentUrl'
|
|
125
121
|
*/
|
|
126
|
-
When('I save current url as {
|
|
127
|
-
cy.url().then(
|
|
128
|
-
|
|
122
|
+
When('I save current url as {value}', function (key) {
|
|
123
|
+
cy.url().then(url => {
|
|
124
|
+
key.set(url);
|
|
129
125
|
});
|
|
130
126
|
});
|
|
131
127
|
|
|
@@ -134,9 +130,9 @@ When('I save current url as {string}', function (key) {
|
|
|
134
130
|
* @param {string} key - key to store value
|
|
135
131
|
* @example I save page title as 'currentTitle'
|
|
136
132
|
*/
|
|
137
|
-
When('I save page title as {
|
|
138
|
-
cy.title().then(
|
|
139
|
-
|
|
133
|
+
When('I save page title as {value}', function (key) {
|
|
134
|
+
cy.title().then(title => {
|
|
135
|
+
key.set(title);
|
|
140
136
|
});
|
|
141
137
|
});
|
|
142
138
|
|
|
@@ -148,11 +144,10 @@ When('I save page title as {string}', function (key) {
|
|
|
148
144
|
* @example I save 'color' css property of 'Checkbox' as 'checkboxColor'
|
|
149
145
|
* @example I save '$propertyName' property of 'Checkbox' as 'checkboxColor'
|
|
150
146
|
*/
|
|
151
|
-
When('I save {
|
|
152
|
-
const propertyName =
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
this.setValue(key, e.css(propertyName));
|
|
147
|
+
When('I save {value} css property of {locator} as {value}', function (property, locator, key) {
|
|
148
|
+
const propertyName = property.value();
|
|
149
|
+
locator.then(e => {
|
|
150
|
+
key.set(e.css(propertyName));
|
|
156
151
|
});
|
|
157
152
|
});
|
|
158
153
|
|
|
@@ -165,7 +160,84 @@ When('I save {string} css property of {string} as {string}', function (property,
|
|
|
165
160
|
* When I save bounding rect of 'Node' as 'boundingRect'
|
|
166
161
|
* Then I expect '$boundingRect.width' to equal '42'
|
|
167
162
|
*/
|
|
168
|
-
When('I save bounding rect of {
|
|
169
|
-
|
|
170
|
-
|
|
163
|
+
When('I save bounding rect of {locator} as {value}', function (locator, key) {
|
|
164
|
+
locator.then(node => {
|
|
165
|
+
key.set(node.get(0).getBoundingClientRect());
|
|
166
|
+
});
|
|
171
167
|
});
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* ##############################
|
|
172
|
+
*/
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Save value to memory
|
|
177
|
+
* @param {string} alias - value to save or alias for previously saved value
|
|
178
|
+
* @param {string} key - key to store value
|
|
179
|
+
* @example I save 'value' to memory as 'key'
|
|
180
|
+
* @example I save '$getRandomUser()' to memory as 'user'
|
|
181
|
+
*/
|
|
182
|
+
When(
|
|
183
|
+
'I save {value} to memory as {value}',
|
|
184
|
+
function (expression, key) {
|
|
185
|
+
key.set(expression.value());
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
When(
|
|
190
|
+
'I save multiline string to memory as {value}:',
|
|
191
|
+
function (key, multilineString) {
|
|
192
|
+
const value = this.value(multilineString);
|
|
193
|
+
key.set(value);
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Save value to memory
|
|
199
|
+
* @param {string} key - key to store value
|
|
200
|
+
* @param {string} value - value to save or alias for previously saved value
|
|
201
|
+
* @example I set 'key' = 'value'
|
|
202
|
+
*/
|
|
203
|
+
When(
|
|
204
|
+
'I set {value} = {value}',
|
|
205
|
+
function (key, expression) {
|
|
206
|
+
key.set(expression.value());
|
|
207
|
+
}
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Save json value to memory
|
|
212
|
+
* @param {string} key - key to store value
|
|
213
|
+
* @param {string} json - multiline string
|
|
214
|
+
* @example I save json to memory as 'key':
|
|
215
|
+
* """
|
|
216
|
+
* {
|
|
217
|
+
* "someKey": "someValue"
|
|
218
|
+
* }
|
|
219
|
+
* """
|
|
220
|
+
*/
|
|
221
|
+
When(
|
|
222
|
+
'I save json to memory as {value}:',
|
|
223
|
+
function (key, json) {
|
|
224
|
+
const value = this.value(json);
|
|
225
|
+
key.set(JSON.parse(value));
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Save key-value pairs to memory
|
|
231
|
+
* @param {string} key - key to store value
|
|
232
|
+
* @param {string} kv - key-value
|
|
233
|
+
* @example I save key-value pairs to memory as 'key':
|
|
234
|
+
* | someKey | 42 |
|
|
235
|
+
* | someOtherKey | $valueFromMemory |
|
|
236
|
+
*/
|
|
237
|
+
When(
|
|
238
|
+
'I save key-value pairs to memory as {value}:',
|
|
239
|
+
function (key, kv) {
|
|
240
|
+
const value = dataTable2Object(this, kv);
|
|
241
|
+
key.set(value);
|
|
242
|
+
}
|
|
243
|
+
);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export class MemoryValue {
|
|
2
|
+
constructor(world, expression) {
|
|
3
|
+
this.world = world;
|
|
4
|
+
this.expression = expression;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Return resolved value
|
|
9
|
+
* @example
|
|
10
|
+
* url.value()
|
|
11
|
+
* @return Promise<any>
|
|
12
|
+
*/
|
|
13
|
+
value() {
|
|
14
|
+
return this.world.value(this.expression)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Set value to memory with provided key
|
|
19
|
+
* @param value any - value to set
|
|
20
|
+
* @example
|
|
21
|
+
* url.set('https://qavajs.github.io/')
|
|
22
|
+
*/
|
|
23
|
+
set(value) {
|
|
24
|
+
this.world.setValue(this.expression, value);
|
|
25
|
+
}
|
|
26
|
+
}
|
package/lib/mouseActions.js
CHANGED
|
@@ -6,8 +6,8 @@ import { parseCoords } from './utils';
|
|
|
6
6
|
* @param {string} button - button to press (left, right, middle)
|
|
7
7
|
* @example When I press left mouse button
|
|
8
8
|
*/
|
|
9
|
-
When('I press {mouseButton} mouse button on {
|
|
10
|
-
const [x, y] = parseCoords(
|
|
9
|
+
When('I press {mouseButton} mouse button on {value}', function (buttons, coords) {
|
|
10
|
+
const [x, y] = parseCoords(coords.value());
|
|
11
11
|
cy.get('body')
|
|
12
12
|
.trigger('mouseenter', x, y)
|
|
13
13
|
.trigger('mouseover', x, y)
|
|
@@ -20,8 +20,8 @@ When('I press {mouseButton} mouse button on {string}', function (buttons, coords
|
|
|
20
20
|
* @param {string} button - button to release (left, right, middle)
|
|
21
21
|
* @example When I release left mouse button
|
|
22
22
|
*/
|
|
23
|
-
When('I release {mouseButton} mouse button on {
|
|
24
|
-
const [x, y] = parseCoords(
|
|
23
|
+
When('I release {mouseButton} mouse button on {value}', function (button, coords) {
|
|
24
|
+
const [x, y] = parseCoords(coords.value());
|
|
25
25
|
cy.get('body')
|
|
26
26
|
.trigger('mouseenter', x, y)
|
|
27
27
|
.trigger('mouseover', x, y)
|
|
@@ -34,8 +34,8 @@ When('I release {mouseButton} mouse button on {string}', function (button, coord
|
|
|
34
34
|
* @param {string} coords - x, y coordinates to move
|
|
35
35
|
* @example When I move mouse to '10, 15'
|
|
36
36
|
*/
|
|
37
|
-
When('I move mouse to {
|
|
38
|
-
const [x, y] = parseCoords(
|
|
37
|
+
When('I move mouse to {value}', function (coords){
|
|
38
|
+
const [x, y] = parseCoords(coords.value());
|
|
39
39
|
cy.get('body')
|
|
40
40
|
.trigger('mouseenter', x, y)
|
|
41
41
|
.trigger('mouseover', x, y)
|
|
@@ -47,9 +47,9 @@ When('I move mouse to {string}', function (coords){
|
|
|
47
47
|
* @param {string} coords - x, y offset to scroll
|
|
48
48
|
* @example When I scroll mouse wheel by '0, 15'
|
|
49
49
|
*/
|
|
50
|
-
When('I scroll mouse wheel by {
|
|
51
|
-
const [x, y] = parseCoords(
|
|
52
|
-
const [deltaX, deltaY] = parseCoords(
|
|
50
|
+
When('I scroll mouse wheel by {value} on {value}', function (offset, coords) {
|
|
51
|
+
const [x, y] = parseCoords(coords.value());
|
|
52
|
+
const [deltaX, deltaY] = parseCoords(offset.value());
|
|
53
53
|
cy.get('body')
|
|
54
54
|
.trigger('mouseenter', x, y)
|
|
55
55
|
.trigger('mouseover', x, y)
|