@qavajs/cypress 1.0.0 → 2.0.0

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 CHANGED
@@ -10,6 +10,9 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
10
10
  :pencil: - chore
11
11
  :microscope: - experimental
12
12
 
13
+ ## [2.0.0]
14
+ - :rocket: implemented new page object approach
15
+
13
16
  ## [0.2.0]
14
17
  - :rocket: added memory write logs support
15
18
 
package/README.md CHANGED
@@ -1,10 +1,9 @@
1
1
  # @qavajs/cypress
2
- qavajs implementation on top of cypress runner
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 {string} url', function (url) {
10
- const urlValue = this.value(url);
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 {string} to {string}', function (value, alias) {
21
- const element = this.element(alias);
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 {string}', function (alias) {
32
- const element = this.element(alias);
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 {string}', function (alias) {
42
- const element = this.element(alias);
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 {string}', function (alias) {
52
- const element = this.element(alias);
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 {string}', function (alias) {
62
- const element = this.element(alias);
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 {string}', function (alias) {
72
- const element = this.element(alias);
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.po.driver = cy;
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.po.driver === cy ? cy.get('iframe') : this.po.driver.find('iframe');
91
- this.po.driver = root
92
- .eq(0)
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 {string} frame', function (frameAlias) {
104
- const frame = this.element(frameAlias);
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 {string}', function (alias) {
148
- const element = this.element(alias);
149
- element.trigger('mouseenter');
150
- element.trigger('mouseover');
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 {string} option from {string} dropdown', function (option, alias) {
162
- const optionValue = this.value(option);
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 {string} dropdown', function (optionIndex, alias) {
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 {string} text in {string} collection',
187
- function (value, alias) {
188
- const resolvedValue = this.value(value);
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 {string}', function (offset) {
201
- const [x, y] = parseCoords(this.value(offset));
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 {string} in {string}', function (offset, alias) {
213
- const [x, y] = parseCoords(this.value(offset));
214
- const element = this.element(alias);
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 {string}', function (alias) {
225
- const element = this.element(alias);
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 {string} file to {string}', function (value, alias) {
237
- const element = this.element(alias);
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 {string} to alert', function (value) {
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 = () => resolvedValue;
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 {string} function', function (functionKey) {
10
- const fnContent = this.value(functionKey);
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 {string} function and save result as {string}', function (functionKey, memoryKey) {
25
- const fnContent = this.value(functionKey);
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
- this.setValue(memoryKey, fn.apply(win));
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 {string} function on {string}', function (functionKey, alias) {
40
- const element = this.element(alias);
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
- element.then((e) => {
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 {string} function on {string} and save result as {string}',
59
- function (functionKey, alias, memoryKey) {
60
- const element = this.element(alias);
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
- element.then((e) => {
65
- this.setValue(memoryKey, fn.apply(win, e));
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 {string} as {string}', function (alias, key) {
10
- const element = this.element(alias);
11
- element.then((e) => {
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 {string} property of {string} as {string}', function (property, alias, key) {
25
- const element = this.element(alias);
26
- const propertyName = this.value(property);
27
- element.then((e) => {
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 {string} attribute of {string} as {string}', function (attribute, alias, key) {
41
- const element = this.element(alias);
42
- const attributeName = this.value(attribute);
43
- element.then((e) => {
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 {string} collection as {string}', function (alias, key) {
55
- const collection = this.element(alias);
56
- collection.then((c) => {
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 {string} collection as {string}',
69
- function (alias, key) {
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
- this.setValue(key, values);
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 {string} attribute of every element of {string} collection as {string}',
89
- function (attribute, alias, key) {
90
- const collection = this.element(alias);
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(attribute));
90
+ values.push(Cypress.$(this).attr(attributeName));
95
91
  })
96
- this.setValue(key, values);
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 {string} property of every element of {string} collection as {string}',
109
- function (property, alias, key) {
110
- const collection = this.element(alias);
111
- collection.then((c) => {
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(property));
110
+ values.push(Cypress.$(this).prop(propertyName));
115
111
  })
116
- this.setValue(key, values);
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 {string}', function (key) {
127
- cy.url().then((url) => {
128
- this.setValue(key, url);
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 {string}', function (key) {
138
- cy.title().then((title) => {
139
- this.setValue(key, title);
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 {string} css property of {string} as {string}', function (property, alias, key) {
152
- const propertyName = this.value(property);
153
- const element = this.element(alias);
154
- element.then((e) => {
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 {string} as {string}', function (alias, key) {
169
- const element = this.element(alias);
170
- element.then(node => this.setValue(key, node.get(0).getBoundingClientRect()));
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
+ }
@@ -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 {string}', function (buttons, coords) {
10
- const [x, y] = parseCoords(this.value(coords));
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 {string}', function (button, coords) {
24
- const [x, y] = parseCoords(this.value(coords));
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 {string}', function (coords){
38
- const [x, y] = parseCoords(this.value(coords));
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 {string} on {string}', function (offset, coords) {
51
- const [x, y] = parseCoords(this.value(coords));
52
- const [deltaX, deltaY] = parseCoords(this.value(offset));
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)