@quickpickle/playwright 0.9.7 → 0.9.9

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.
@@ -1,8 +1,12 @@
1
1
  import { Given, When, Then } from 'quickpickle';
2
+ import { expect } from '@playwright/test';
3
+ import { getLocator, setValue, sanitizeFilepath, defaultScreenshotPath } from './helpers.mjs';
2
4
  import path from 'node:path';
3
5
  import url from 'node:url';
4
6
 
5
7
  const projectRoot = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), '..');
8
+ // ================
9
+ // Navigation
6
10
  Given('I am on {string}', async function (world, path) {
7
11
  let url = new URL(path, world.baseUrl);
8
12
  await world.page.goto(url.href);
@@ -18,63 +22,116 @@ When(`I navigate/go to {string}`, async function (world, path) {
18
22
  When('I load the file {string}', async (world, path) => {
19
23
  await world.page.goto(`file://${projectRoot}/${path}`);
20
24
  });
25
+ When('I go back/forward/forwards', async function (world) {
26
+ let direction = world.info.step?.match(/(back|forwards?)$/)[0];
27
+ if (direction === 'back')
28
+ await world.page.goBack();
29
+ else
30
+ await world.page.goForward();
31
+ });
32
+ // ================
33
+ // Interaction
21
34
  When('I click/press/tap/touch (on ){string}', async function (world, identifier) {
22
- await world.page.getByText(identifier, { exact: true }).click();
35
+ let locator = world.page.getByText(identifier, { exact: true });
36
+ await expect(locator).toBeVisible({ timeout: 1000 });
37
+ await locator.click();
23
38
  });
24
39
  When('I click/press/tap/touch (on )the {string} {word}', async function (world, identifier, role) {
25
- let locator;
26
- if (role === 'element')
27
- locator = await world.page.getByText(identifier, { exact: true }).or(world.page.locator(identifier));
28
- else
29
- locator = await world.page.getByRole(role, { name: identifier });
40
+ let locator = await getLocator(world.page, identifier, role);
41
+ await expect(locator).toBeVisible({ timeout: 1000 });
30
42
  await locator.click();
31
43
  });
32
44
  When('I focus/select/activate (on ){string}', async function (world, identifier) {
33
- let locator = await world.page.getByText(identifier, { exact: true }).or(world.page.locator(identifier));
45
+ let locator = await world.page.getByText(identifier, { exact: true });
46
+ await expect(locator).toBeVisible({ timeout: 1000 });
34
47
  await locator.focus();
35
48
  });
36
49
  When('I focus/select/activate (on )the {string} {word}', async function (world, identifier, role) {
37
- let locator;
38
- if (role === 'element')
39
- locator = await world.page.getByText(identifier, { exact: true }).or(world.page.locator(identifier));
40
- else
41
- locator = await world.page.getByRole(role, { name: identifier });
50
+ let locator = await getLocator(world.page, identifier, role);
51
+ await expect(locator).toBeVisible({ timeout: 1000 });
42
52
  await locator.focus();
43
53
  });
44
- When("for (the ){string} I enter/fill (in ){string}", async function (world, identifier, text) {
45
- let locator = await world.page.getByLabel(identifier).or(world.page.getByPlaceholder(identifier)).or(world.page.locator(identifier));
46
- await locator.fill(text);
54
+ // ================
55
+ // Typing
56
+ When("for/in/on (the ){string} I type {string}", async function (world, identifier, value) {
57
+ let locator = await getLocator(world.page, identifier, 'input');
58
+ await locator.pressSequentially(value);
59
+ });
60
+ When("for/in/on (the ){string} {word} I type {string}", async function (world, identifier, role, value) {
61
+ let locator = await getLocator(world.page, identifier, role);
62
+ await locator.pressSequentially(value);
63
+ });
64
+ When('I type the following keys: {}', async function (world, keys) {
65
+ let keyPresses = keys.split(' ');
66
+ for (let key of keyPresses)
67
+ await world.page.keyboard.press(key, { delay: world.playwrightConfig.keyboardDelay });
68
+ });
69
+ When("for/in/on (the ){string} I type the following keys: {}", async function (world, identifier, keys) {
70
+ let locator = await getLocator(world.page, identifier, 'input');
71
+ for (let key of keys)
72
+ await locator.press(key, { delay: world.playwrightConfig.keyboardDelay });
73
+ });
74
+ When("for/in/on (the ){string} {word} I type the following keys: {}", async function (world, identifier, role, keys) {
75
+ let locator = await getLocator(world.page, identifier, role);
76
+ for (let key of keys)
77
+ await locator.press(key, { delay: world.playwrightConfig.keyboardDelay });
78
+ });
79
+ // ================
80
+ // Forms
81
+ When("for/in/on (the ){string} I enter/fill/select (in ){string}", async function (world, identifier, value) {
82
+ let locator = await getLocator(world.page, identifier, 'input');
83
+ await setValue(locator, value);
84
+ });
85
+ When("for/in/on (the ){string} {word} I enter/fill/select (in ){string}", async function (world, identifier, role, value) {
86
+ let locator = await getLocator(world.page, identifier, role);
87
+ await setValue(locator, value);
88
+ });
89
+ When("for/in/on (the ){string} I enter/fill/select (in )the following( text):", async function (world, identifier, value) {
90
+ let locator = await getLocator(world.page, identifier, 'input');
91
+ await setValue(locator, value.toString());
47
92
  });
48
- When("for (the ){string} I enter/fill (in )the following( text):", async function (world, identifier, text) {
49
- let locator = await world.page.getByLabel(identifier).or(world.page.getByPlaceholder(identifier)).or(world.page.locator(identifier));
50
- await locator.fill(text);
93
+ When("for/in/on (the ){string} {word} I enter/fill/select (in )the following( text):", async function (world, identifier, role, value) {
94
+ let locator = await getLocator(world.page, identifier, role);
95
+ await setValue(locator, value.toString());
51
96
  });
52
97
  When('I enter/fill (in )the following( fields):', async function (world, table) {
98
+ let rows = table.raw();
99
+ let hasRole = rows[0].length === 3;
53
100
  for (let row of table.raw()) {
54
- let [identifier, text] = row;
55
- let locator = await world.page.getByLabel(identifier).or(world.page.getByPlaceholder(identifier)).or(world.page.locator(identifier));
56
- let tag = await locator.evaluate(e => e.tagName.toLowerCase());
57
- let type = await locator.getAttribute('type');
58
- if (tag === 'select') {
59
- await locator.selectOption(text);
60
- }
61
- else if (type === 'checkbox' || type === 'radio') {
62
- let checked = (['', 'false', 'no', 'unchecked', 'null', 'undefined', '0']).includes(text.toLowerCase()) ? false : true;
63
- await locator.setChecked(checked);
64
- }
65
- else {
66
- await locator.fill(text);
101
+ let [identifier, role, value] = row;
102
+ if (!hasRole) {
103
+ value = role;
104
+ role = 'input';
67
105
  }
106
+ let locator = await getLocator(world.page, identifier, role);
107
+ await setValue(locator, value);
68
108
  }
69
109
  });
70
- When('I wait for {string} to be attached/detatched/visible/hidden', async function (world, identifier) {
110
+ When('I check (the ){string}( radio)( checkbox)( box)', async function (world, indentifier) {
111
+ let locator = await getLocator(world.page, indentifier, 'input');
112
+ await locator.check();
113
+ });
114
+ When('I uncheck (the ){string}( checkbox)( box)', async function (world, indentifier) {
115
+ let locator = await getLocator(world.page, indentifier, 'input');
116
+ await locator.uncheck();
117
+ });
118
+ // ================
119
+ // Waiting
120
+ When('I wait for {string} to be attached/detatched/visible/hidden', async function (world, text) {
71
121
  let state = world.info.step?.match(/(attached|detatched|visible|hidden)$/)[0];
72
- let locator = await world.page.getByText(identifier, { exact: true }).or(world.page.getByLabel(identifier)).or(world.page.locator(identifier));
73
- await locator.waitFor({ state });
122
+ let locator = world.page.getByText(text);
123
+ await locator.waitFor({ state, timeout: 5000 });
124
+ });
125
+ When('I wait for a/an/the {string} {word} to be attached/detatched/visible/hidden', async function (world, identifier, role) {
126
+ let state = world.info.step?.match(/(attached|detatched|visible|hidden)$/)[0];
127
+ let locator = await getLocator(world.page, identifier, role);
128
+ await locator.waitFor({ state, timeout: 5000 });
74
129
  });
75
130
  When('I wait for {int}ms', async function (world, num) {
76
131
  await world.page.waitForTimeout(num);
77
132
  });
133
+ // ================
134
+ // Scrolling
78
135
  When('I scroll down/up/left/right', async function (world) {
79
136
  let direction = world.info.step?.match(/(down|up|left|right)$/)[0];
80
137
  let num = 100;
@@ -90,24 +147,24 @@ When('I scroll down/up/left/right {int}(px)( pixels)', async function (world, nu
90
147
  await world.page.mouse.wheel(direction === 'right' ? num : -num, 0);
91
148
  await world.page.mouse.wheel(0, direction === 'down' ? num : -num);
92
149
  });
93
- When('I type the following keys: {}', async function (world, keys) {
94
- let keyPresses = keys.split(' ');
95
- for (let key of keyPresses) {
96
- await world.page.keyboard.press(key);
97
- }
98
- });
99
- When('I go back/forwards?', async function (world) {
100
- let direction = world.info.step?.match(/(back|forwards?)$/)[0];
101
- if (direction === 'back')
102
- await world.page.goBack();
103
- else
104
- await world.page.goForward();
105
- });
150
+ // ================
151
+ // Screenshots
106
152
  Then('(I )take (a )screenshot', async function (world) {
107
- await world.page.screenshot({ path: `${projectRoot}/${world.playwrightConfig.screenshotDir}/${world.info.rule ? world.info.rule + '__' + world.info.scenario : world.info.scenario}__${world.info.line}.png`.replace(/\/\//g, '/') });
153
+ let path = sanitizeFilepath(`${projectRoot}/${defaultScreenshotPath(world)}`);
154
+ await world.page.screenshot({ path });
108
155
  });
109
156
  Then('(I )take (a )screenshot named {string}', async function (world, name) {
110
- await world.page.screenshot({ path: `${projectRoot}/${world.playwrightConfig.screenshotDir}/${name}.png`.replace(/\/\//g, '/') });
157
+ let explodedTags = world.info.explodedIdx ? `_(${world.info.tags.join(',')})` : '';
158
+ let path = sanitizeFilepath(`${projectRoot}/${world.playwrightConfig.screenshotDir}/${name}${explodedTags}.png`);
159
+ await world.page.screenshot({ path });
160
+ });
161
+ // ================
162
+ // Browser size
163
+ Given('the browser size is (set to ){word}', async function (world, browserSizeTag) {
164
+ await world.setViewportSize(browserSizeTag);
165
+ });
166
+ Given('the browser size is (set to ){int} x {int}', async function (world, width, height) {
167
+ await world.page.setViewportSize({ width, height });
111
168
  });
112
169
 
113
170
  export { projectRoot };
@@ -1 +1 @@
1
- {"version":3,"file":"actions.steps.mjs","sources":["../src/actions.steps.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAMa,MAAA,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAC;AAE/F,KAAK,CAAC,kBAAkB,EAAE,gBAAgB,KAAqB,EAAE,IAAI,EAAA;IACnE,IAAI,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;IACtC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AACjC,CAAC,CAAC,CAAA;AACF,IAAI,CAAC,CAAkB,gBAAA,CAAA,EAAE,gBAAgB,KAAqB,EAAE,IAAI,EAAA;IAClE,IAAI,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI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AAA,IAAI,GAAG,YAAY,CAAA,IAAA,CAAM,CAAC,CAAA;IAChH,MAAM,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;AACvC,CAAC,CAAC,CAAA;AAEF;AACA;AACA,KAAK,CAAC,qCAAqC,EAAE,gBAAgB,KAAqB,EAAE,cAAqB,EAAA;AACvG,IAAA,MAAM,KAAK,CAAC,eAAe,CAAC,cAAc,CAAC,CAAA;AAC7C,CAAC,CAAC,CAAA;AACF,KAAK,CAAC,4CAA4C,EAAE,gBAAgB,KAAqB,EAAE,KAAY,EAAE,MAAa,EAAA;AACpH,IAAA,MAAM,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;AACrD,CAAC,CAAC;;;;"}
@@ -0,0 +1,53 @@
1
+ 'use strict';
2
+
3
+ // Locator helper function
4
+ async function getLocator(el, identifier, role, text = null) {
5
+ let locator;
6
+ if (role === 'element')
7
+ locator = await el.locator(identifier);
8
+ else if (role === 'input')
9
+ locator = await el.getByLabel(identifier).or(el.getByPlaceholder(identifier));
10
+ else
11
+ locator = await el.getByRole(role, { name: identifier });
12
+ if (text)
13
+ return await locator.filter({ hasText: text });
14
+ return locator;
15
+ }
16
+ async function setValue(locator, value) {
17
+ let { tag, type, role } = await locator.evaluate((el) => ({ tag: el.tagName.toLowerCase(), type: el.getAttribute('type')?.toLowerCase(), role: el.getAttribute('role')?.toLowerCase() }));
18
+ if (tag === 'select') {
19
+ let values = value.split(/\s*(?<!\\),\s*/).map((v) => v.replace(/\\,/g, ','));
20
+ await locator.selectOption(values);
21
+ }
22
+ else if (type === 'checkbox' || type === 'radio' || role === 'checkbox') {
23
+ let check = !(['false', 'no', 'unchecked', '', 'null', 'undefined', '0'].includes(value.toString().toLowerCase()));
24
+ if (check)
25
+ await locator.check();
26
+ else
27
+ await locator.uncheck();
28
+ }
29
+ else {
30
+ await locator.fill(value);
31
+ }
32
+ }
33
+ async function testMetatag(page, name, expected, exact) {
34
+ let actual;
35
+ if (name === 'title')
36
+ actual = await page.title();
37
+ else
38
+ actual = await (await page.locator(`meta[name="${name}"]`)).getAttribute('content');
39
+ return exact ? actual === expected : actual?.includes(expected);
40
+ }
41
+ function sanitizeFilepath(filepath) {
42
+ return filepath.replace(/\/\/+/g, '/').replace(/\/[\.~]+\//g, '/');
43
+ }
44
+ function defaultScreenshotPath(world) {
45
+ return `${world.playwrightConfig.screenshotDir}/${world.toString().replace(/^.+?Feature: /, 'Feature: ').replace(' ' + world.info.step, '')}.png`;
46
+ }
47
+
48
+ exports.defaultScreenshotPath = defaultScreenshotPath;
49
+ exports.getLocator = getLocator;
50
+ exports.sanitizeFilepath = sanitizeFilepath;
51
+ exports.setValue = setValue;
52
+ exports.testMetatag = testMetatag;
53
+ //# sourceMappingURL=helpers.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.cjs","sources":["../src/helpers.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAGA;AACO,eAAe,UAAU,CAAC,EAAe,EAAE,UAAiB,EAAE,IAAW,EAAE,IAAA,GAAiB,IAAI,EAAA;AACrG,IAAA,IAAI,OAAe,CAAA;IACnB,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;SACzD,IAAI,IAAI,KAAK,OAAO;AAAE,QAAA,OAAO,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAA;;AACnG,QAAA,OAAO,GAAG,MAAM,EAAE,CAAC,SAAS,CAAC,IAAW,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAA;AACpE,IAAA,IAAI,IAAI;QAAE,OAAO,MAAM,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA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AS,EAAE,IAAW,EAAE,QAAe,EAAE,KAAa,EAAA;AACtF,IAAA,IAAI,MAAkB,CAAA;IAEtB,IAAI,IAAI,KAAK,OAAO;AAAE,QAAA,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;;AAC5C,QAAA,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,CAAA,WAAA,EAAc,IAAI,CAAA,EAAA,CAAI,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,CAAA;AAExF,IAAA,OAAO,KAAK,GAAI,MAAM,KAAK,QAAQ,GAAG,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAA;AAClE,CAAC;AAEK,SAAU,gBAAgB,CAAC,QAAe,EAAA;AAC9C,IAAA,OAAO,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAAA;AACpE,CAAC;AAEK,SAAU,qBAAqB,CAAC,KAAqB,EAAA;AACzD,IAAA,OAAO,CAAG,EAAA,KAAK,CAAC,gBAAgB,CAAC,aAAa,CAAA,CAAA,EAAI,KAAK,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC,OAAO,CAAC,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAA;AACnJ;;;;;;;;"}
@@ -0,0 +1,7 @@
1
+ import { Locator, Page } from "playwright-core";
2
+ import { PlaywrightWorld } from "./PlaywrightWorld";
3
+ export declare function getLocator(el: Locator | Page, identifier: string, role: string, text?: string | null): Promise<Locator>;
4
+ export declare function setValue(locator: Locator, value: string | any): Promise<void>;
5
+ export declare function testMetatag(page: Page, name: string, expected: string, exact: boolean): Promise<boolean | undefined>;
6
+ export declare function sanitizeFilepath(filepath: string): string;
7
+ export declare function defaultScreenshotPath(world: PlaywrightWorld): string;
@@ -0,0 +1,47 @@
1
+ // Locator helper function
2
+ async function getLocator(el, identifier, role, text = null) {
3
+ let locator;
4
+ if (role === 'element')
5
+ locator = await el.locator(identifier);
6
+ else if (role === 'input')
7
+ locator = await el.getByLabel(identifier).or(el.getByPlaceholder(identifier));
8
+ else
9
+ locator = await el.getByRole(role, { name: identifier });
10
+ if (text)
11
+ return await locator.filter({ hasText: text });
12
+ return locator;
13
+ }
14
+ async function setValue(locator, value) {
15
+ let { tag, type, role } = await locator.evaluate((el) => ({ tag: el.tagName.toLowerCase(), type: el.getAttribute('type')?.toLowerCase(), role: el.getAttribute('role')?.toLowerCase() }));
16
+ if (tag === 'select') {
17
+ let values = value.split(/\s*(?<!\\),\s*/).map((v) => v.replace(/\\,/g, ','));
18
+ await locator.selectOption(values);
19
+ }
20
+ else if (type === 'checkbox' || type === 'radio' || role === 'checkbox') {
21
+ let check = !(['false', 'no', 'unchecked', '', 'null', 'undefined', '0'].includes(value.toString().toLowerCase()));
22
+ if (check)
23
+ await locator.check();
24
+ else
25
+ await locator.uncheck();
26
+ }
27
+ else {
28
+ await locator.fill(value);
29
+ }
30
+ }
31
+ async function testMetatag(page, name, expected, exact) {
32
+ let actual;
33
+ if (name === 'title')
34
+ actual = await page.title();
35
+ else
36
+ actual = await (await page.locator(`meta[name="${name}"]`)).getAttribute('content');
37
+ return exact ? actual === expected : actual?.includes(expected);
38
+ }
39
+ function sanitizeFilepath(filepath) {
40
+ return filepath.replace(/\/\/+/g, '/').replace(/\/[\.~]+\//g, '/');
41
+ }
42
+ function defaultScreenshotPath(world) {
43
+ return `${world.playwrightConfig.screenshotDir}/${world.toString().replace(/^.+?Feature: /, 'Feature: ').replace(' ' + world.info.step, '')}.png`;
44
+ }
45
+
46
+ export { defaultScreenshotPath, getLocator, sanitizeFilepath, setValue, testMetatag };
47
+ //# sourceMappingURL=helpers.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.mjs","sources":["../src/helpers.ts"],"sourcesContent":[null],"names":[],"mappings":"AAGA;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