webship-js 2.0.3 → 2.0.4

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.
Files changed (49) hide show
  1. package/.circleci/config.yml +7 -31
  2. package/.drone.yml +68 -0
  3. package/.harness/webship-js-pipeline.yml +101 -0
  4. package/.semaphore/semaphore.yml +58 -0
  5. package/.teamcity/pom.xml +52 -0
  6. package/.teamcity/settings.kts +92 -0
  7. package/.travis.yml +24 -3
  8. package/AGENTS.md +2 -2
  9. package/CLAUDE.md +2 -2
  10. package/Jenkinsfile +54 -0
  11. package/azure-pipelines.yml +82 -0
  12. package/bamboo-specs/bamboo.yml +131 -0
  13. package/buildspec.yml +56 -0
  14. package/cloudbuild.yaml +49 -0
  15. package/codefresh.yml +77 -0
  16. package/cucumber.js +40 -3
  17. package/docs/04-step-reference.md +74 -3
  18. package/docs/16-ci-cd.md +879 -0
  19. package/docs/README.md +113 -0
  20. package/docs/global-settings.md +51 -0
  21. package/examples/video-demo.html +43 -0
  22. package/package.json +1 -1
  23. package/tests/features/video.feature +18 -0
  24. package/tests/step-definitions/a11y.steps.js +3 -1
  25. package/tests/step-definitions/action.steps.js +2 -2
  26. package/tests/step-definitions/api.steps.js +17 -16
  27. package/tests/step-definitions/assertion.steps.js +2 -2
  28. package/tests/step-definitions/auth.steps.js +3 -1
  29. package/tests/step-definitions/clock.steps.js +38 -38
  30. package/tests/step-definitions/debug.steps.js +13 -5
  31. package/tests/step-definitions/element.steps.js +47 -5
  32. package/tests/step-definitions/file-download.steps.js +38 -20
  33. package/tests/step-definitions/form.steps.js +6 -6
  34. package/tests/step-definitions/iframe.steps.js +65 -15
  35. package/tests/step-definitions/input.steps.js +47 -8
  36. package/tests/step-definitions/javascript.steps.js +195 -34
  37. package/tests/step-definitions/keyboard.steps.js +38 -4
  38. package/tests/step-definitions/modal.steps.js +39 -14
  39. package/tests/step-definitions/network.steps.js +61 -19
  40. package/tests/step-definitions/responsive.steps.js +3 -1
  41. package/tests/step-definitions/selectors.steps.js +19 -17
  42. package/tests/step-definitions/video.steps.js +178 -0
  43. package/tests/step-definitions/web-first.steps.js +3 -1
  44. package/tests/step-definitions/webship.js +234 -15
  45. package/tests/step-definitions/xml.steps.js +4 -2
  46. package/tests/step-definitions/yaml.steps.js +13 -11
  47. package/videos/README.md +32 -0
  48. package/.travis-ci.yml +0 -16
  49. package/docs/index.md +0 -104
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ const { friendly } = require('./webship');
4
+
3
5
  // Element interactions and visual / positional assertions using Playwright.
4
6
 
5
7
  const { Given, When, Then } = require('@cucumber/cucumber');
@@ -153,7 +155,15 @@ Then('the element {string} should be centered in the viewport', async function (
153
155
  *
154
156
  */
155
157
  When(/^(I |we )*click on the element "([^"]*)"$/, async function (pronoun, sel) {
156
- await this.page.locator(sel).first().click();
158
+ try {
159
+ await this.page.locator(sel).first().click();
160
+ } catch (e) {
161
+ throw friendly({
162
+ action: `click on the element "${sel}"`,
163
+ cause: e,
164
+ hint: `check that the element exists on the page, is visible, and is clickable.`,
165
+ });
166
+ }
157
167
  });
158
168
 
159
169
  /**
@@ -170,7 +180,15 @@ When(/^(I |we )*click on the element "([^"]*)"$/, async function (pronoun, sel)
170
180
  *
171
181
  */
172
182
  When(/^(I |we )*trigger the JS event "([^"]*)" on the element "([^"]*)"$/, async function (pronoun, event, sel) {
173
- await this.page.locator(sel).first().dispatchEvent(event);
183
+ try {
184
+ await this.page.locator(sel).first().dispatchEvent(event);
185
+ } catch (e) {
186
+ throw friendly({
187
+ action: `trigger the "${event}" event on "${sel}"`,
188
+ cause: e,
189
+ hint: `use a standard event name like click, change, input, focus, or blur.`,
190
+ });
191
+ }
174
192
  });
175
193
 
176
194
  /**
@@ -184,7 +202,15 @@ When(/^(I |we )*trigger the JS event "([^"]*)" on the element "([^"]*)"$/, async
184
202
  *
185
203
  */
186
204
  When(/^(I |we )*scroll to the element "([^"]*)"$/, async function (pronoun, sel) {
187
- await this.page.locator(sel).first().scrollIntoViewIfNeeded();
205
+ try {
206
+ await this.page.locator(sel).first().scrollIntoViewIfNeeded();
207
+ } catch (e) {
208
+ throw friendly({
209
+ action: `scroll to "${sel}"`,
210
+ cause: e,
211
+ hint: `check the element exists on the page and was not removed before scrolling.`,
212
+ });
213
+ }
188
214
  });
189
215
 
190
216
  /**
@@ -198,7 +224,15 @@ When(/^(I |we )*scroll to the element "([^"]*)"$/, async function (pronoun, sel)
198
224
  *
199
225
  */
200
226
  When(/^(I |we )*hover over the element "([^"]*)"$/, async function (pronoun, sel) {
201
- await this.page.locator(sel).first().hover();
227
+ try {
228
+ await this.page.locator(sel).first().hover();
229
+ } catch (e) {
230
+ throw friendly({
231
+ action: `hover over "${sel}"`,
232
+ cause: e,
233
+ hint: `check the element exists, is visible, and is not covered by another element.`,
234
+ });
235
+ }
202
236
  });
203
237
 
204
238
  /**
@@ -212,7 +246,15 @@ When(/^(I |we )*hover over the element "([^"]*)"$/, async function (pronoun, sel
212
246
  *
213
247
  */
214
248
  When(/^(I |we )*focus on the element "([^"]*)"$/, async function (pronoun, sel) {
215
- await this.page.locator(sel).first().focus();
249
+ try {
250
+ await this.page.locator(sel).first().focus();
251
+ } catch (e) {
252
+ throw friendly({
253
+ action: `focus on "${sel}"`,
254
+ cause: e,
255
+ hint: `the element must be focusable — an input, button, link, or have a tabindex.`,
256
+ });
257
+ }
216
258
  });
217
259
 
218
260
  /**
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ const { friendly } = require('./webship');
4
+
3
5
  // Validate file downloads triggered via URL or link click.
4
6
 
5
7
  const { When, Then } = require('@cucumber/cucumber');
@@ -30,15 +32,23 @@ function tmpDownloadDir() {
30
32
  */
31
33
  When(/^(I |we )*download the file from the URL "([^"]*)"$/, async function (pronoun, url) {
32
34
  const target = url.startsWith('http') ? url : (this.launchUrl || '') + url;
33
- const resp = await this.page.request.get(target);
34
- assert.strictEqual(resp.status(), 200, `Download failed with status ${resp.status()}.`);
35
- const buffer = await resp.body();
36
- const cd = resp.headers()['content-disposition'] || '';
37
- const m = /filename="?([^"]+)"?/.exec(cd);
38
- const filename = m ? m[1] : path.basename(new URL(target).pathname) || 'download';
39
- const filePath = path.join(tmpDownloadDir(), filename);
40
- fs.writeFileSync(filePath, buffer);
41
- this._lastDownload = { path: filePath, filename, content: buffer };
35
+ try {
36
+ const resp = await this.page.request.get(target);
37
+ assert.strictEqual(resp.status(), 200, `Download failed with status ${resp.status()}.`);
38
+ const buffer = await resp.body();
39
+ const cd = resp.headers()['content-disposition'] || '';
40
+ const m = /filename="?([^"]+)"?/.exec(cd);
41
+ const filename = m ? m[1] : path.basename(new URL(target).pathname) || 'download';
42
+ const filePath = path.join(tmpDownloadDir(), filename);
43
+ fs.writeFileSync(filePath, buffer);
44
+ this._lastDownload = { path: filePath, filename, content: buffer };
45
+ } catch (e) {
46
+ throw friendly({
47
+ action: `download "${target}"`,
48
+ cause: e,
49
+ hint: `check the URL is reachable and returns a successful response.`,
50
+ });
51
+ }
42
52
  });
43
53
 
44
54
  /**
@@ -52,17 +62,25 @@ When(/^(I |we )*download the file from the URL "([^"]*)"$/, async function (pron
52
62
  *
53
63
  */
54
64
  When(/^(I |we )*download the file from the link "([^"]*)"$/, async function (pronoun, linkText) {
55
- const [download] = await Promise.all([
56
- this.page.waitForEvent('download'),
57
- this.page.getByRole('link', { name: linkText }).first().click().catch(() =>
58
- this.page.locator(`a:has-text("${linkText}")`).first().click()
59
- ),
60
- ]);
61
- const filename = download.suggestedFilename();
62
- const filePath = path.join(tmpDownloadDir(), filename);
63
- await download.saveAs(filePath);
64
- const content = fs.readFileSync(filePath);
65
- this._lastDownload = { path: filePath, filename, content };
65
+ try {
66
+ const [download] = await Promise.all([
67
+ this.page.waitForEvent('download'),
68
+ this.page.getByRole('link', { name: linkText }).first().click().catch(() =>
69
+ this.page.locator(`a:has-text("${linkText}")`).first().click()
70
+ ),
71
+ ]);
72
+ const filename = download.suggestedFilename();
73
+ const filePath = path.join(tmpDownloadDir(), filename);
74
+ await download.saveAs(filePath);
75
+ const content = fs.readFileSync(filePath);
76
+ this._lastDownload = { path: filePath, filename, content };
77
+ } catch (e) {
78
+ throw friendly({
79
+ action: `download from link "${linkText}"`,
80
+ cause: e,
81
+ hint: `the link must offer a downloadable file (not open in a new tab). If the link only navigates, use "When I download the file from the URL ..." instead.`,
82
+ });
83
+ }
66
84
  });
67
85
 
68
86
  /**
@@ -5,7 +5,7 @@
5
5
  // check / uncheck, radio buttons.
6
6
 
7
7
  const { When } = require('@cucumber/cucumber');
8
- const { buildSelector, fillField } = require('./webship');
8
+ const { buildSelector, fillField, friendly } = require('./webship');
9
9
 
10
10
  // ---------------------------------------------------------------------------
11
11
  // Fill — by label, attribute, table, reverse syntax
@@ -177,7 +177,7 @@ When(/^(I |we )*select "([^"]*)?" from "([^"]*)?"$/, async function (pronounCase
177
177
  try {
178
178
  await loc.selectOption(option);
179
179
  } catch (e) {
180
- throw new Error(
180
+ throw friendly(
181
181
  `Could not select "${option}" from "${selectList}".\n` +
182
182
  ` ${(e.message || '').split('\n')[0]}\n` +
183
183
  ` Hints:\n` +
@@ -231,7 +231,7 @@ When(/^(I |we )*additionally select "([^"]*)" from "([^"]*)"$/, async function (
231
231
  }, option);
232
232
 
233
233
  if (nextValueForLabel === null) {
234
- throw new Error(`Option "${option}" not found in select "${select}".`);
234
+ throw friendly(`Option "${option}" not found in select "${select}".`);
235
235
  }
236
236
 
237
237
  const combined = Array.from(new Set([...currentValues, nextValueForLabel]));
@@ -264,7 +264,7 @@ When(/^(I |we )*check "([^"]*)?"$/, async function (pronounCase, item) {
264
264
  }
265
265
  }
266
266
  } catch (e) {
267
- throw new Error(
267
+ throw friendly(
268
268
  `Could not check "${item}".\n` +
269
269
  ` ${(e.message || '').split('\n')[0]}\n` +
270
270
  ` Hints: confirm the label / id / class matches; ensure the input is visible and not disabled.`
@@ -294,7 +294,7 @@ When(/^(I |we )*uncheck "([^"]*)?"$/, async function (pronounCase, item) {
294
294
  }
295
295
  }
296
296
  } catch (e) {
297
- throw new Error(
297
+ throw friendly(
298
298
  `Could not uncheck "${item}".\n` +
299
299
  ` ${(e.message || '').split('\n')[0]}\n` +
300
300
  ` Hints: confirm the label / id / class matches; ensure the input is visible and not disabled.`
@@ -324,7 +324,7 @@ When(/^(I |we )*select radio button "([^"]*)?"$/, async function (pronounCase, i
324
324
  }
325
325
  }
326
326
  } catch (e) {
327
- throw new Error(
327
+ throw friendly(
328
328
  `Could not select radio button "${item}".\n` +
329
329
  ` ${(e.message || '').split('\n')[0]}\n` +
330
330
  ` Hints: try matching by [value=...], by label text, or by #id / .class.`
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ const { friendly } = require('./webship');
4
+
3
5
  // Iframe / frame steps backed by Playwright's `frameLocator` API.
4
6
  //
5
7
  // Frames are addressed by CSS selector. Once switched, frame-scoped
@@ -13,6 +15,14 @@ function frameRoot(world) {
13
15
  return world.frame || world.page;
14
16
  }
15
17
 
18
+ function explain(action, detail, e) {
19
+ return friendly({
20
+ action,
21
+ cause: e,
22
+ hint: `wait for the iframe to load first ("When I wait for \\"iframe\\" to appear"). Detail: ${detail}.`,
23
+ });
24
+ }
25
+
16
26
  /**
17
27
  * Switch the active scope to an iframe addressed by CSS selector.
18
28
  *
@@ -24,8 +34,12 @@ function frameRoot(world) {
24
34
  *
25
35
  */
26
36
  When(/^(I |we )*switch to (the )?iframe "([^"]*)"$/, async function (pronoun, theCase, sel) {
27
- if (!this._rootPage) this._rootPage = this.page;
28
- this.frame = this.page.frameLocator(sel);
37
+ try {
38
+ if (!this._rootPage) this._rootPage = this.page;
39
+ this.frame = this.page.frameLocator(sel);
40
+ } catch (e) {
41
+ throw explain(`switch to iframe "${sel}"`, `selector tried: ${sel}`, e);
42
+ }
29
43
  });
30
44
 
31
45
  /**
@@ -39,8 +53,12 @@ When(/^(I |we )*switch to (the )?iframe "([^"]*)"$/, async function (pronoun, th
39
53
  *
40
54
  */
41
55
  When(/^(I |we )*switch to iframe with locator "([^"]*)"$/, async function (pronoun, sel) {
42
- if (!this._rootPage) this._rootPage = this.page;
43
- this.frame = this.page.frameLocator(sel);
56
+ try {
57
+ if (!this._rootPage) this._rootPage = this.page;
58
+ this.frame = this.page.frameLocator(sel);
59
+ } catch (e) {
60
+ throw explain(`switch to iframe with locator "${sel}"`, `locator: ${sel}`, e);
61
+ }
44
62
  });
45
63
 
46
64
  /**
@@ -74,8 +92,12 @@ When(/^(I |we )*switch to the root document$/, async function () {
74
92
  *
75
93
  */
76
94
  When(/^(I |we )*switch to the iframe with title "([^"]*)"$/, async function (pronoun, title) {
77
- if (!this._rootPage) this._rootPage = this.page;
78
- this.frame = this.page.frameLocator(`iframe[title="${title}"]`);
95
+ try {
96
+ if (!this._rootPage) this._rootPage = this.page;
97
+ this.frame = this.page.frameLocator(`iframe[title="${title}"]`);
98
+ } catch (e) {
99
+ throw explain(`switch to iframe by title "${title}"`, `selector: iframe[title="${title}"]`, e);
100
+ }
79
101
  });
80
102
 
81
103
  /**
@@ -89,8 +111,12 @@ When(/^(I |we )*switch to the iframe with title "([^"]*)"$/, async function (pro
89
111
  *
90
112
  */
91
113
  When(/^(I |we )*switch to the iframe with name "([^"]*)"$/, async function (pronoun, name) {
92
- if (!this._rootPage) this._rootPage = this.page;
93
- this.frame = this.page.frameLocator(`iframe[name="${name}"]`);
114
+ try {
115
+ if (!this._rootPage) this._rootPage = this.page;
116
+ this.frame = this.page.frameLocator(`iframe[name="${name}"]`);
117
+ } catch (e) {
118
+ throw explain(`switch to iframe by name "${name}"`, `selector: iframe[name="${name}"]`, e);
119
+ }
94
120
  });
95
121
 
96
122
  // ---------------------------------------------------------------------------
@@ -108,9 +134,17 @@ When(/^(I |we )*switch to the iframe with name "([^"]*)"$/, async function (pron
108
134
  *
109
135
  */
110
136
  When(/^(I |we )*click "([^"]*)" inside the iframe$/, async function (pronoun, text) {
111
- const root = frameRoot(this);
112
- if (!root.locator) throw new Error('No active iframe. Switch first.');
113
- await root.locator(`text="${text}"`).first().click();
137
+ try {
138
+ const root = frameRoot(this);
139
+ if (!root.locator) throw friendly('No active iframe. Switch first.');
140
+ await root.locator(`text="${text}"`).first().click();
141
+ } catch (e) {
142
+ throw friendly({
143
+ action: `click "${text}" inside the iframe`,
144
+ cause: e,
145
+ hint: `switch to the iframe first ("When I switch to iframe '<selector>'"), then check the visible text matches exactly.`,
146
+ });
147
+ }
114
148
  });
115
149
 
116
150
  /**
@@ -126,8 +160,16 @@ When(/^(I |we )*click "([^"]*)" inside the iframe$/, async function (pronoun, te
126
160
  *
127
161
  */
128
162
  When(/^(I |we )*click "([^"]*)" by attr inside the iframe$/, async function (pronoun, attrValue) {
129
- const root = frameRoot(this);
130
- await root.locator(`#${attrValue}, .${attrValue}, [name="${attrValue}"], [data-testid="${attrValue}"]`).first().click();
163
+ try {
164
+ const root = frameRoot(this);
165
+ await root.locator(`#${attrValue}, .${attrValue}, [name="${attrValue}"], [data-testid="${attrValue}"]`).first().click();
166
+ } catch (e) {
167
+ throw friendly({
168
+ action: `click "${attrValue}" by attribute inside the iframe`,
169
+ cause: e,
170
+ hint: `switch to the iframe first; checked id, class, [name], [data-testid] — none matched.`,
171
+ });
172
+ }
131
173
  });
132
174
 
133
175
  /**
@@ -141,8 +183,16 @@ When(/^(I |we )*click "([^"]*)" by attr inside the iframe$/, async function (pro
141
183
  *
142
184
  */
143
185
  When(/^(I |we )*fill in "([^"]*)" with "([^"]*)" inside the iframe$/, async function (pronoun, field, value) {
144
- const root = frameRoot(this);
145
- await root.locator(`[name="${field}"], #${field}`).first().fill(value);
186
+ try {
187
+ const root = frameRoot(this);
188
+ await root.locator(`[name="${field}"], #${field}`).first().fill(value);
189
+ } catch (e) {
190
+ throw friendly({
191
+ action: `fill "${field}" inside the iframe`,
192
+ cause: e,
193
+ hint: `switch to the iframe first; checked [name] and id — neither matched.`,
194
+ });
195
+ }
146
196
  });
147
197
 
148
198
  /**
@@ -1,10 +1,20 @@
1
1
  'use strict';
2
2
 
3
+ const { friendly } = require('./webship');
4
+
3
5
  // Pointer input steps not covered by the core element/click steps:
4
6
  // hover variants, drag-and-drop, double-click, right-click, viewport size.
5
7
 
6
8
  const { When } = require('@cucumber/cucumber');
7
9
 
10
+ function explainPtr(action, sel, e) {
11
+ return friendly({
12
+ action: `${action} "${sel}"`,
13
+ cause: e,
14
+ hint: `check the element exists on the page, is visible, and is not covered by an overlay.`,
15
+ });
16
+ }
17
+
8
18
  // ---------------------------------------------------------------------------
9
19
  // Hover (variants)
10
20
  // ---------------------------------------------------------------------------
@@ -20,7 +30,8 @@ const { When } = require('@cucumber/cucumber');
20
30
  *
21
31
  */
22
32
  When(/^(I |we )*hover over "([^"]*)"$/, async function (pronoun, sel) {
23
- await this.page.locator(sel).first().hover();
33
+ try { await this.page.locator(sel).first().hover(); }
34
+ catch (e) { throw explainPtr('hover over', sel, e); }
24
35
  });
25
36
 
26
37
  /**
@@ -34,7 +45,8 @@ When(/^(I |we )*hover over "([^"]*)"$/, async function (pronoun, sel) {
34
45
  *
35
46
  */
36
47
  When(/^(I |we )*move the pointer to "([^"]*)"$/, async function (pronoun, sel) {
37
- await this.page.locator(sel).first().hover();
48
+ try { await this.page.locator(sel).first().hover(); }
49
+ catch (e) { throw explainPtr('move pointer to', sel, e); }
38
50
  });
39
51
 
40
52
  // ---------------------------------------------------------------------------
@@ -52,7 +64,8 @@ When(/^(I |we )*move the pointer to "([^"]*)"$/, async function (pronoun, sel) {
52
64
  *
53
65
  */
54
66
  When(/^(I |we )*double[- ]click on "([^"]*)"$/, async function (pronoun, sel) {
55
- await this.page.locator(sel).first().dblclick();
67
+ try { await this.page.locator(sel).first().dblclick(); }
68
+ catch (e) { throw explainPtr('double-click', sel, e); }
56
69
  });
57
70
 
58
71
  /**
@@ -66,7 +79,8 @@ When(/^(I |we )*double[- ]click on "([^"]*)"$/, async function (pronoun, sel) {
66
79
  *
67
80
  */
68
81
  When(/^(I |we )*right[- ]click on "([^"]*)"$/, async function (pronoun, sel) {
69
- await this.page.locator(sel).first().click({ button: 'right' });
82
+ try { await this.page.locator(sel).first().click({ button: 'right' }); }
83
+ catch (e) { throw explainPtr('right-click', sel, e); }
70
84
  });
71
85
 
72
86
  /**
@@ -80,7 +94,8 @@ When(/^(I |we )*right[- ]click on "([^"]*)"$/, async function (pronoun, sel) {
80
94
  *
81
95
  */
82
96
  When(/^(I |we )*middle[- ]click on "([^"]*)"$/, async function (pronoun, sel) {
83
- await this.page.locator(sel).first().click({ button: 'middle' });
97
+ try { await this.page.locator(sel).first().click({ button: 'middle' }); }
98
+ catch (e) { throw explainPtr('middle-click', sel, e); }
84
99
  });
85
100
 
86
101
  /**
@@ -96,7 +111,15 @@ When(/^(I |we )*middle[- ]click on "([^"]*)"$/, async function (pronoun, sel) {
96
111
  *
97
112
  */
98
113
  When(/^(I |we )*click on "([^"]*)" while holding "([^"]*)"$/, async function (pronoun, sel, key) {
99
- await this.page.locator(sel).first().click({ modifiers: [key] });
114
+ try {
115
+ await this.page.locator(sel).first().click({ modifiers: [key] });
116
+ } catch (e) {
117
+ throw friendly({
118
+ action: `click "${sel}" while holding "${key}"`,
119
+ cause: e,
120
+ hint: `modifier must be one of: Shift, Control, Alt, Meta.`,
121
+ });
122
+ }
100
123
  });
101
124
 
102
125
  // ---------------------------------------------------------------------------
@@ -114,7 +137,15 @@ When(/^(I |we )*click on "([^"]*)" while holding "([^"]*)"$/, async function (pr
114
137
  *
115
138
  */
116
139
  When(/^(I |we )*drag "([^"]*)" to "([^"]*)"$/, async function (pronoun, source, target) {
117
- await this.page.locator(source).first().dragTo(this.page.locator(target).first());
140
+ try {
141
+ await this.page.locator(source).first().dragTo(this.page.locator(target).first());
142
+ } catch (e) {
143
+ throw friendly({
144
+ action: `drag "${source}" to "${target}"`,
145
+ cause: e,
146
+ hint: `both items must exist on the page; the target must accept drops.`,
147
+ });
148
+ }
118
149
  });
119
150
 
120
151
  // ---------------------------------------------------------------------------
@@ -132,7 +163,15 @@ When(/^(I |we )*drag "([^"]*)" to "([^"]*)"$/, async function (pronoun, source,
132
163
  *
133
164
  */
134
165
  When(/^(I |we )*set the viewport size to (\d+)x(\d+)$/, async function (pronoun, w, h) {
135
- await this.page.setViewportSize({ width: parseInt(w, 10), height: parseInt(h, 10) });
166
+ try {
167
+ await this.page.setViewportSize({ width: parseInt(w, 10), height: parseInt(h, 10) });
168
+ } catch (e) {
169
+ throw friendly({
170
+ action: `set viewport size to ${w}x${h}`,
171
+ cause: e,
172
+ hint: `the browser was opened in fluid-viewport mode; set a fixed viewport in playwright.config.ts contextOptions.viewport.`,
173
+ });
174
+ }
136
175
  });
137
176
 
138
177
  // ---------------------------------------------------------------------------