playwright-cucumber-ts-steps 1.1.8 → 1.1.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.
- package/LICENSE +21 -0
- package/dist/backend/actions/click.d.ts +132 -1
- package/dist/backend/actions/click.d.ts.map +1 -1
- package/dist/backend/actions/click.js +122 -53
- package/dist/backend/actions/find.d.ts +243 -1
- package/dist/backend/actions/find.d.ts.map +1 -1
- package/dist/backend/actions/find.js +196 -72
- package/dist/backend/actions/form.d.ts +37 -1
- package/dist/backend/actions/form.d.ts.map +1 -1
- package/dist/backend/actions/form.js +55 -3
- package/dist/backend/actions/formTable.d.ts +25 -1
- package/dist/backend/actions/formTable.d.ts.map +1 -1
- package/dist/backend/actions/formTable.js +27 -5
- package/dist/backend/actions/frames.d.ts +53 -1
- package/dist/backend/actions/frames.d.ts.map +1 -1
- package/dist/backend/actions/frames.js +48 -11
- package/dist/backend/actions/inputs.d.ts +139 -1
- package/dist/backend/actions/inputs.d.ts.map +1 -1
- package/dist/backend/actions/inputs.js +113 -43
- package/dist/backend/actions/interactions.d.ts +61 -1
- package/dist/backend/actions/interactions.d.ts.map +1 -1
- package/dist/backend/actions/interactions.js +65 -10
- package/dist/backend/actions/keyboard.d.ts +70 -1
- package/dist/backend/actions/keyboard.d.ts.map +1 -1
- package/dist/backend/actions/keyboard.js +59 -23
- package/dist/backend/actions/misc.d.ts +134 -1
- package/dist/backend/actions/misc.d.ts.map +1 -1
- package/dist/backend/actions/misc.js +106 -42
- package/dist/backend/actions/mobile.d.ts +74 -1
- package/dist/backend/actions/mobile.d.ts.map +1 -1
- package/dist/backend/actions/mobile.js +74 -13
- package/dist/backend/actions/mouse.d.ts +79 -1
- package/dist/backend/actions/mouse.d.ts.map +1 -1
- package/dist/backend/actions/mouse.js +66 -21
- package/dist/backend/actions/navigation.d.ts +48 -1
- package/dist/backend/actions/navigation.d.ts.map +1 -1
- package/dist/backend/actions/navigation.js +42 -15
- package/dist/backend/actions/waits.d.ts +55 -1
- package/dist/backend/actions/waits.d.ts.map +1 -1
- package/dist/backend/actions/waits.js +49 -17
- package/dist/backend/api/assertions.d.ts +32 -1
- package/dist/backend/api/assertions.d.ts.map +1 -1
- package/dist/backend/api/assertions.js +37 -9
- package/dist/backend/api/mock.d.ts +34 -1
- package/dist/backend/api/mock.d.ts.map +1 -1
- package/dist/backend/api/mock.js +37 -10
- package/dist/backend/api/network.d.ts +60 -1
- package/dist/backend/api/network.d.ts.map +1 -1
- package/dist/backend/api/network.js +53 -21
- package/dist/backend/api/requests.d.ts +43 -1
- package/dist/backend/api/requests.d.ts.map +1 -1
- package/dist/backend/api/requests.js +49 -17
- package/dist/backend/assertions/pageState.d.ts +40 -1
- package/dist/backend/assertions/pageState.d.ts.map +1 -1
- package/dist/backend/assertions/pageState.js +33 -12
- package/dist/backend/assertions/text.d.ts +46 -1
- package/dist/backend/assertions/text.d.ts.map +1 -1
- package/dist/backend/assertions/text.js +51 -8
- package/dist/backend/assertions/visibility.d.ts +102 -1
- package/dist/backend/assertions/visibility.d.ts.map +1 -1
- package/dist/backend/assertions/visibility.js +86 -36
- package/dist/backend/auth/index.js +2 -2
- package/dist/backend/db/steps.d.ts +35 -1
- package/dist/backend/db/steps.d.ts.map +1 -1
- package/dist/backend/db/steps.js +48 -15
- package/dist/backend/elements/alerts.d.ts +35 -1
- package/dist/backend/elements/alerts.d.ts.map +1 -1
- package/dist/backend/elements/alerts.js +39 -6
- package/dist/backend/elements/forms.d.ts +44 -1
- package/dist/backend/elements/forms.d.ts.map +1 -1
- package/dist/backend/elements/forms.js +50 -11
- package/dist/backend/elements/frames.d.ts +36 -1
- package/dist/backend/elements/frames.d.ts.map +1 -1
- package/dist/backend/elements/frames.js +43 -13
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +3 -4
- package/package.json +52 -12
|
@@ -33,27 +33,52 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
|
|
37
|
-
const state_1 = require("./state");
|
|
36
|
+
exports.MakePostRequestWithFile = exports.MakePostRequestWithTable = exports.MakeDeleteRequest = exports.MakeGetRequest = void 0;
|
|
38
37
|
const fs = __importStar(require("fs"));
|
|
39
38
|
const path = __importStar(require("path"));
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const registry_1 = require("../../core/registry");
|
|
40
|
+
const state_1 = require("./state");
|
|
41
|
+
/**
|
|
42
|
+
* @module ApiActions
|
|
43
|
+
*/
|
|
44
|
+
/**
|
|
45
|
+
* Performs a standard HTTP GET request and stores the response in the global API state.
|
|
46
|
+
* * @example
|
|
47
|
+
* ```gherkin
|
|
48
|
+
* When I make a GET request to "[https://api.example.com/users](https://api.example.com/users)"
|
|
49
|
+
* ```
|
|
50
|
+
* * @param url - The full URL or endpoint path.
|
|
51
|
+
*/
|
|
52
|
+
exports.MakeGetRequest = (0, registry_1.Step)("I make a GET request to {string}", async (page, url) => {
|
|
42
53
|
const response = await page.request.get(url);
|
|
43
54
|
state_1.apiState.setResponse(response);
|
|
44
55
|
console.log(`GET ${url} - Status: ${response.status()}`);
|
|
45
56
|
});
|
|
46
|
-
|
|
47
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Performs a standard HTTP DELETE request and stores the response in the global API state.
|
|
59
|
+
* * @example
|
|
60
|
+
* ```gherkin
|
|
61
|
+
* When I make a DELETE request to "/api/users/1"
|
|
62
|
+
* ```
|
|
63
|
+
* * @param url - The endpoint path to delete.
|
|
64
|
+
*/
|
|
65
|
+
exports.MakeDeleteRequest = (0, registry_1.Step)("I make a DELETE request to {string}", async (page, url) => {
|
|
48
66
|
const response = await page.request.delete(url);
|
|
49
67
|
state_1.apiState.setResponse(response);
|
|
68
|
+
console.log(`DELETE ${url} - Status: ${response.status()}`);
|
|
50
69
|
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Performs an HTTP POST request using a Gherkin Data Table as the JSON payload.
|
|
72
|
+
* * @example
|
|
73
|
+
* ```gherkin
|
|
74
|
+
* When I make a POST request to "/api/users" with data
|
|
75
|
+
* | name | John |
|
|
76
|
+
* | job | Dev |
|
|
77
|
+
* ```
|
|
78
|
+
* * @param url - The target endpoint.
|
|
79
|
+
* @param tableData - The Gherkin Data Table (automatically converted to a JSON object).
|
|
80
|
+
*/
|
|
81
|
+
exports.MakePostRequestWithTable = (0, registry_1.Step)("I make a POST request to {string} with data", async (page, url, tableData) => {
|
|
57
82
|
if (!tableData)
|
|
58
83
|
throw new Error("This step requires a Data Table.");
|
|
59
84
|
// Convert Table [ ["key", "val"], ["k2", "v2"] ] -> Object { key: "val", k2: "v2" }
|
|
@@ -66,16 +91,22 @@ const path = __importStar(require("path"));
|
|
|
66
91
|
headers: { "Content-Type": "application/json" },
|
|
67
92
|
});
|
|
68
93
|
state_1.apiState.setResponse(response);
|
|
94
|
+
console.log(`POST ${url} (Table) - Status: ${response.status()}`);
|
|
69
95
|
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Performs an HTTP POST request using the contents of a local JSON file as the payload.
|
|
98
|
+
* * @example
|
|
99
|
+
* ```gherkin
|
|
100
|
+
* When I make a POST request to "/api/users" with payload from "data/user.json"
|
|
101
|
+
* ```
|
|
102
|
+
* * @param url - The target endpoint.
|
|
103
|
+
* @param filePath - Path to the JSON file relative to the project root.
|
|
104
|
+
*/
|
|
105
|
+
exports.MakePostRequestWithFile = (0, registry_1.Step)("I make a POST request to {string} with payload from {string}", async (page, url, filePath) => {
|
|
74
106
|
const fullPath = path.resolve(process.cwd(), filePath);
|
|
75
107
|
if (!fs.existsSync(fullPath)) {
|
|
76
108
|
throw new Error(`❌ Payload file not found at: ${fullPath}`);
|
|
77
109
|
}
|
|
78
|
-
// Read and parse JSON
|
|
79
110
|
const fileContent = fs.readFileSync(fullPath, "utf8");
|
|
80
111
|
const payload = JSON.parse(fileContent);
|
|
81
112
|
const response = await page.request.post(url, {
|
|
@@ -83,4 +114,5 @@ const path = __importStar(require("path"));
|
|
|
83
114
|
headers: { "Content-Type": "application/json" },
|
|
84
115
|
});
|
|
85
116
|
state_1.apiState.setResponse(response);
|
|
117
|
+
console.log(`POST ${url} (File: ${filePath}) - Status: ${response.status()}`);
|
|
86
118
|
});
|
|
@@ -1,2 +1,41 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module BrowserAssertions
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Asserts that the current browser URL contains a specific substring.
|
|
6
|
+
* Useful for verifying redirection to a general area (e.g., a dashboard).
|
|
7
|
+
* * @example
|
|
8
|
+
* ```gherkin
|
|
9
|
+
* Then I expect the url to contain "dashboard"
|
|
10
|
+
* ```
|
|
11
|
+
* * @param part - The substring to search for in the URL.
|
|
12
|
+
*/
|
|
13
|
+
export declare const ExpectUrlToContain: void;
|
|
14
|
+
/**
|
|
15
|
+
* Asserts that the current browser URL exactly matches the provided string.
|
|
16
|
+
* * @example
|
|
17
|
+
* ```gherkin
|
|
18
|
+
* Then I expect the url to be "[https://example.com/login](https://example.com/login)"
|
|
19
|
+
* ```
|
|
20
|
+
* * @param url - The expected full URL.
|
|
21
|
+
*/
|
|
22
|
+
export declare const ExpectUrlToBe: void;
|
|
23
|
+
/**
|
|
24
|
+
* Asserts that the page's `<title>` tag contains a specific substring.
|
|
25
|
+
* * @example
|
|
26
|
+
* ```gherkin
|
|
27
|
+
* Then I expect the title to contain "Welcome"
|
|
28
|
+
* ```
|
|
29
|
+
* * @param part - The substring expected within the page title.
|
|
30
|
+
*/
|
|
31
|
+
export declare const ExpectTitleToContain: void;
|
|
32
|
+
/**
|
|
33
|
+
* Asserts that the page's `<title>` tag exactly matches the provided string.
|
|
34
|
+
* * @example
|
|
35
|
+
* ```gherkin
|
|
36
|
+
* Then I expect the title to be "My Application - Home"
|
|
37
|
+
* ```
|
|
38
|
+
* * @param title - The expected full page title.
|
|
39
|
+
*/
|
|
40
|
+
export declare const ExpectTitleToBe: void;
|
|
2
41
|
//# sourceMappingURL=pageState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pageState.d.ts","sourceRoot":"","sources":["../../../src/backend/assertions/pageState.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"pageState.d.ts","sourceRoot":"","sources":["../../../src/backend/assertions/pageState.ts"],"names":[],"mappings":"AAGA;;GAEG;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,MAM9B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,MAGxB,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,MAMhC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,MAG1B,CAAC"}
|
|
@@ -1,36 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExpectTitleToBe = exports.ExpectTitleToContain = exports.ExpectUrlToBe = exports.ExpectUrlToContain = void 0;
|
|
3
4
|
const test_1 = require("@playwright/test");
|
|
4
5
|
const registry_1 = require("../../core/registry");
|
|
5
6
|
/**
|
|
6
|
-
*
|
|
7
|
-
* Pattern: Then I expect the url to contain "dashboard"
|
|
7
|
+
* @module BrowserAssertions
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Asserts that the current browser URL contains a specific substring.
|
|
11
|
+
* Useful for verifying redirection to a general area (e.g., a dashboard).
|
|
12
|
+
* * @example
|
|
13
|
+
* ```gherkin
|
|
14
|
+
* Then I expect the url to contain "dashboard"
|
|
15
|
+
* ```
|
|
16
|
+
* * @param part - The substring to search for in the URL.
|
|
17
|
+
*/
|
|
18
|
+
exports.ExpectUrlToContain = (0, registry_1.Step)("I expect the url to contain {string}", async (page, part) => {
|
|
10
19
|
await (0, test_1.expect)(page).toHaveURL(new RegExp(part));
|
|
11
20
|
console.log(`✅ URL contains "${part}"`);
|
|
12
21
|
});
|
|
13
22
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
23
|
+
* Asserts that the current browser URL exactly matches the provided string.
|
|
24
|
+
* * @example
|
|
25
|
+
* ```gherkin
|
|
26
|
+
* Then I expect the url to be "[https://example.com/login](https://example.com/login)"
|
|
27
|
+
* ```
|
|
28
|
+
* * @param url - The expected full URL.
|
|
16
29
|
*/
|
|
17
|
-
(0, registry_1.Step)("I expect the url to be {string}", async (page, url) => {
|
|
30
|
+
exports.ExpectUrlToBe = (0, registry_1.Step)("I expect the url to be {string}", async (page, url) => {
|
|
18
31
|
await (0, test_1.expect)(page).toHaveURL(url);
|
|
19
32
|
console.log(`✅ URL is "${url}"`);
|
|
20
33
|
});
|
|
21
34
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
35
|
+
* Asserts that the page's `<title>` tag contains a specific substring.
|
|
36
|
+
* * @example
|
|
37
|
+
* ```gherkin
|
|
38
|
+
* Then I expect the title to contain "Welcome"
|
|
39
|
+
* ```
|
|
40
|
+
* * @param part - The substring expected within the page title.
|
|
24
41
|
*/
|
|
25
|
-
(0, registry_1.Step)("I expect the title to contain {string}", async (page, part) => {
|
|
42
|
+
exports.ExpectTitleToContain = (0, registry_1.Step)("I expect the title to contain {string}", async (page, part) => {
|
|
26
43
|
await (0, test_1.expect)(page).toHaveTitle(new RegExp(part));
|
|
27
44
|
console.log(`✅ Title contains "${part}"`);
|
|
28
45
|
});
|
|
29
46
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
47
|
+
* Asserts that the page's `<title>` tag exactly matches the provided string.
|
|
48
|
+
* * @example
|
|
49
|
+
* ```gherkin
|
|
50
|
+
* Then I expect the title to be "My Application - Home"
|
|
51
|
+
* ```
|
|
52
|
+
* * @param title - The expected full page title.
|
|
32
53
|
*/
|
|
33
|
-
(0, registry_1.Step)("I expect the title to be {string}", async (page, title) => {
|
|
54
|
+
exports.ExpectTitleToBe = (0, registry_1.Step)("I expect the title to be {string}", async (page, title) => {
|
|
34
55
|
await (0, test_1.expect)(page).toHaveTitle(title);
|
|
35
56
|
console.log(`✅ Title is "${title}"`);
|
|
36
57
|
});
|
|
@@ -1,2 +1,47 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module ElementAssertions
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Asserts that an element exactly matches the specified text.
|
|
6
|
+
* * @example
|
|
7
|
+
* ```gherkin
|
|
8
|
+
* Then I expect "h1" to have text "Welcome Home"
|
|
9
|
+
* ```
|
|
10
|
+
* * @param selector - The CSS or Playwright selector for the element.
|
|
11
|
+
* @param text - The exact text string expected.
|
|
12
|
+
*/
|
|
13
|
+
export declare const ExpectElementToHaveText: void;
|
|
14
|
+
/**
|
|
15
|
+
* Asserts that an element contains the specified substring.
|
|
16
|
+
* Useful for long paragraphs or dynamic content.
|
|
17
|
+
* * @example
|
|
18
|
+
* ```gherkin
|
|
19
|
+
* Then I expect ".error-msg" to contain text "invalid credentials"
|
|
20
|
+
* ```
|
|
21
|
+
* * @param selector - The CSS or Playwright selector for the element.
|
|
22
|
+
* @param text - The partial text string expected to be present.
|
|
23
|
+
*/
|
|
24
|
+
export declare const ExpectElementToContainText: void;
|
|
25
|
+
/**
|
|
26
|
+
* Asserts that a form field (input, textarea, select) has a specific value.
|
|
27
|
+
* * @example
|
|
28
|
+
* ```gherkin
|
|
29
|
+
* Then I expect "#username" to have value "john_doe"
|
|
30
|
+
* ```
|
|
31
|
+
* * @param selector - The selector for the input element.
|
|
32
|
+
* @param value - The expected value of the field.
|
|
33
|
+
*/
|
|
34
|
+
export declare const ExpectElementToHaveValue: void;
|
|
35
|
+
/**
|
|
36
|
+
* Asserts that a specific attribute of an element matches the expected value.
|
|
37
|
+
* Common use cases include checking `href` for links or `src` for images.
|
|
38
|
+
* * @example
|
|
39
|
+
* ```gherkin
|
|
40
|
+
* Then I expect "a#terms-link" to have attribute "href" with value "/terms-and-conditions"
|
|
41
|
+
* ```
|
|
42
|
+
* * @param selector - The selector for the element.
|
|
43
|
+
* @param attr - The name of the attribute (e.g., "class", "href", "data-testid").
|
|
44
|
+
* @param value - The expected value of that attribute.
|
|
45
|
+
*/
|
|
46
|
+
export declare const ExpectElementAttributeValue: void;
|
|
2
47
|
//# sourceMappingURL=text.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/backend/assertions/text.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/backend/assertions/text.ts"],"names":[],"mappings":"AAGA;;GAEG;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,MAMnC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,MAMtC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,MAMpC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,MAMvC,CAAC"}
|
|
@@ -1,20 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExpectElementAttributeValue = exports.ExpectElementToHaveValue = exports.ExpectElementToContainText = exports.ExpectElementToHaveText = void 0;
|
|
3
4
|
const test_1 = require("@playwright/test");
|
|
4
5
|
const registry_1 = require("../../core/registry");
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* @module ElementAssertions
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Asserts that an element exactly matches the specified text.
|
|
11
|
+
* * @example
|
|
12
|
+
* ```gherkin
|
|
13
|
+
* Then I expect "h1" to have text "Welcome Home"
|
|
14
|
+
* ```
|
|
15
|
+
* * @param selector - The CSS or Playwright selector for the element.
|
|
16
|
+
* @param text - The exact text string expected.
|
|
17
|
+
*/
|
|
18
|
+
exports.ExpectElementToHaveText = (0, registry_1.Step)("I expect {string} to have text {string}", async (page, selector, text) => {
|
|
7
19
|
await (0, test_1.expect)(page.locator(selector)).toHaveText(text);
|
|
20
|
+
console.log(`✅ Element "${selector}" has exact text "${text}"`);
|
|
8
21
|
});
|
|
9
|
-
|
|
10
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Asserts that an element contains the specified substring.
|
|
24
|
+
* Useful for long paragraphs or dynamic content.
|
|
25
|
+
* * @example
|
|
26
|
+
* ```gherkin
|
|
27
|
+
* Then I expect ".error-msg" to contain text "invalid credentials"
|
|
28
|
+
* ```
|
|
29
|
+
* * @param selector - The CSS or Playwright selector for the element.
|
|
30
|
+
* @param text - The partial text string expected to be present.
|
|
31
|
+
*/
|
|
32
|
+
exports.ExpectElementToContainText = (0, registry_1.Step)("I expect {string} to contain text {string}", async (page, selector, text) => {
|
|
11
33
|
await (0, test_1.expect)(page.locator(selector)).toContainText(text);
|
|
34
|
+
console.log(`✅ Element "${selector}" contains text "${text}"`);
|
|
12
35
|
});
|
|
13
|
-
|
|
14
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Asserts that a form field (input, textarea, select) has a specific value.
|
|
38
|
+
* * @example
|
|
39
|
+
* ```gherkin
|
|
40
|
+
* Then I expect "#username" to have value "john_doe"
|
|
41
|
+
* ```
|
|
42
|
+
* * @param selector - The selector for the input element.
|
|
43
|
+
* @param value - The expected value of the field.
|
|
44
|
+
*/
|
|
45
|
+
exports.ExpectElementToHaveValue = (0, registry_1.Step)("I expect {string} to have value {string}", async (page, selector, value) => {
|
|
15
46
|
await (0, test_1.expect)(page.locator(selector)).toHaveValue(value);
|
|
47
|
+
console.log(`✅ Input "${selector}" has value "${value}"`);
|
|
16
48
|
});
|
|
17
|
-
|
|
18
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Asserts that a specific attribute of an element matches the expected value.
|
|
51
|
+
* Common use cases include checking `href` for links or `src` for images.
|
|
52
|
+
* * @example
|
|
53
|
+
* ```gherkin
|
|
54
|
+
* Then I expect "a#terms-link" to have attribute "href" with value "/terms-and-conditions"
|
|
55
|
+
* ```
|
|
56
|
+
* * @param selector - The selector for the element.
|
|
57
|
+
* @param attr - The name of the attribute (e.g., "class", "href", "data-testid").
|
|
58
|
+
* @param value - The expected value of that attribute.
|
|
59
|
+
*/
|
|
60
|
+
exports.ExpectElementAttributeValue = (0, registry_1.Step)("I expect {string} to have attribute {string} with value {string}", async (page, selector, attr, value) => {
|
|
19
61
|
await (0, test_1.expect)(page.locator(selector)).toHaveAttribute(attr, value);
|
|
62
|
+
console.log(`✅ Element "${selector}" attribute "${attr}" is "${value}"`);
|
|
20
63
|
});
|
|
@@ -1,2 +1,103 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module ActiveElementAssertions
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Asserts that the currently stored (active) element is visible in the viewport.
|
|
6
|
+
* * @example
|
|
7
|
+
* ```gherkin
|
|
8
|
+
* Then I expect element to be visible
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare const ExpectActiveVisible: void;
|
|
12
|
+
/**
|
|
13
|
+
* Asserts that an element with a given selector or description is visible in the viewport.
|
|
14
|
+
* * @example
|
|
15
|
+
* ```gherkin
|
|
16
|
+
* Then I expect "Submit Button" to be visible
|
|
17
|
+
* Then I expect ".login-form" to be visible
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const ExpectStringVisible: void;
|
|
21
|
+
/**
|
|
22
|
+
* Asserts that the currently stored (active) element is hidden or detached from the DOM.
|
|
23
|
+
* * @example
|
|
24
|
+
* ```gherkin
|
|
25
|
+
* Then I expect element to be hidden
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const ExpectActiveHidden: void;
|
|
29
|
+
/**
|
|
30
|
+
* Asserts that the currently stored (active) element is enabled (not disabled).
|
|
31
|
+
* * @example
|
|
32
|
+
* ```gherkin
|
|
33
|
+
* Then I expect element to be enabled
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare const ExpectActiveEnabled: void;
|
|
37
|
+
/**
|
|
38
|
+
* Asserts that the currently stored (active) element is disabled.
|
|
39
|
+
* * @example
|
|
40
|
+
* ```gherkin
|
|
41
|
+
* Then I expect element to be disabled
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare const ExpectActiveDisabled: void;
|
|
45
|
+
/**
|
|
46
|
+
* Asserts that the currently stored (active) element has the exact text specified.
|
|
47
|
+
* * @example
|
|
48
|
+
* ```gherkin
|
|
49
|
+
* Then I expect element to have text "Submit Order"
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare const ExpectActiveText: void;
|
|
53
|
+
/**
|
|
54
|
+
* Asserts that the currently stored (active) element contains the specified partial text.
|
|
55
|
+
* * @example
|
|
56
|
+
* ```gherkin
|
|
57
|
+
* Then I expect element to contain text "Order #"
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare const ExpectActiveContainText: void;
|
|
61
|
+
/**
|
|
62
|
+
* Asserts that the currently stored (active) element (input/select) has a specific value.
|
|
63
|
+
* Supports aliases (e.g., `@orderId`) to compare against stored variables.
|
|
64
|
+
* * @example
|
|
65
|
+
* ```gherkin
|
|
66
|
+
* Then I expect element to have value "12345"
|
|
67
|
+
* Then I expect element to have value "@savedUserEmail"
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare const ExpectActiveValue: void;
|
|
71
|
+
/**
|
|
72
|
+
* Asserts that the currently stored (active) element possesses a specific attribute.
|
|
73
|
+
* * @example
|
|
74
|
+
* ```gherkin
|
|
75
|
+
* Then I expect element to have attribute "required"
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare const ExpectActiveAttribute: void;
|
|
79
|
+
/**
|
|
80
|
+
* Asserts that the currently stored (active) element has an attribute with a specific value.
|
|
81
|
+
* * @example
|
|
82
|
+
* ```gherkin
|
|
83
|
+
* Then I expect element to have attribute "type" with value "password"
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare const ExpectActiveAttributeValue: void;
|
|
87
|
+
/**
|
|
88
|
+
* Performs a visual comparison of the entire page against a baseline screenshot.
|
|
89
|
+
* * @example
|
|
90
|
+
* ```gherkin
|
|
91
|
+
* Then I expect the page screenshot to match "landing-page.png"
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export declare const ExpectPageScreenshotMatch: void;
|
|
95
|
+
/**
|
|
96
|
+
* Performs a visual comparison of the active element against a baseline screenshot.
|
|
97
|
+
* * @example
|
|
98
|
+
* ```gherkin
|
|
99
|
+
* Then I expect the element screenshot to match "login-button.png"
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export declare const ExpectElementScreenshotMatch: void;
|
|
2
103
|
//# sourceMappingURL=visibility.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visibility.d.ts","sourceRoot":"","sources":["../../../src/backend/assertions/visibility.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"visibility.d.ts","sourceRoot":"","sources":["../../../src/backend/assertions/visibility.ts"],"names":[],"mappings":"AAIA;;GAEG;AAMH;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,MAI9B,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,MAI9B,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,MAI7B,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,MAI9B,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,MAI/B,CAAC;AAMH;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,MAO5B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,MAOnC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,MAa7B,CAAC;AAMF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,MAOjC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,MAOtC,CAAC;AAMF;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,MAMrC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,MAOxC,CAAC"}
|
|
@@ -1,43 +1,72 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExpectElementScreenshotMatch = exports.ExpectPageScreenshotMatch = exports.ExpectActiveAttributeValue = exports.ExpectActiveAttribute = exports.ExpectActiveValue = exports.ExpectActiveContainText = exports.ExpectActiveText = exports.ExpectActiveDisabled = exports.ExpectActiveEnabled = exports.ExpectActiveHidden = exports.ExpectStringVisible = exports.ExpectActiveVisible = void 0;
|
|
3
4
|
const test_1 = require("@playwright/test");
|
|
4
5
|
const registry_1 = require("../../core/registry");
|
|
5
6
|
const state_1 = require("../utils/state");
|
|
7
|
+
/**
|
|
8
|
+
* @module ActiveElementAssertions
|
|
9
|
+
*/
|
|
6
10
|
// ===============================
|
|
7
11
|
// 1. VISIBILITY & STATE CHECKS
|
|
8
12
|
// ===============================
|
|
9
13
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
14
|
+
* Asserts that the currently stored (active) element is visible in the viewport.
|
|
15
|
+
* * @example
|
|
16
|
+
* ```gherkin
|
|
17
|
+
* Then I expect element to be visible
|
|
18
|
+
* ```
|
|
12
19
|
*/
|
|
13
|
-
(0, registry_1.Step)("I expect element to be visible", async (page) => {
|
|
20
|
+
exports.ExpectActiveVisible = (0, registry_1.Step)("I expect element to be visible", async (page) => {
|
|
14
21
|
const element = (0, state_1.getActiveElement)(page);
|
|
15
22
|
await (0, test_1.expect)(element).toBeVisible();
|
|
16
23
|
console.log("✅ Element is visible");
|
|
17
24
|
});
|
|
18
25
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
26
|
+
* Asserts that an element with a given selector or description is visible in the viewport.
|
|
27
|
+
* * @example
|
|
28
|
+
* ```gherkin
|
|
29
|
+
* Then I expect "Submit Button" to be visible
|
|
30
|
+
* Then I expect ".login-form" to be visible
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
exports.ExpectStringVisible = (0, registry_1.Step)("I expect {string} to be visible", async (page, selector) => {
|
|
34
|
+
const element = page.locator(selector);
|
|
35
|
+
await (0, test_1.expect)(element).toBeVisible();
|
|
36
|
+
console.log(`✅ "${selector}" is visible`);
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Asserts that the currently stored (active) element is hidden or detached from the DOM.
|
|
40
|
+
* * @example
|
|
41
|
+
* ```gherkin
|
|
42
|
+
* Then I expect element to be hidden
|
|
43
|
+
* ```
|
|
21
44
|
*/
|
|
22
|
-
(0, registry_1.Step)("I expect element to be hidden", async (page) => {
|
|
45
|
+
exports.ExpectActiveHidden = (0, registry_1.Step)("I expect element to be hidden", async (page) => {
|
|
23
46
|
const element = (0, state_1.getActiveElement)(page);
|
|
24
47
|
await (0, test_1.expect)(element).toBeHidden();
|
|
25
48
|
console.log("✅ Element is hidden");
|
|
26
49
|
});
|
|
27
50
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
51
|
+
* Asserts that the currently stored (active) element is enabled (not disabled).
|
|
52
|
+
* * @example
|
|
53
|
+
* ```gherkin
|
|
54
|
+
* Then I expect element to be enabled
|
|
55
|
+
* ```
|
|
30
56
|
*/
|
|
31
|
-
(0, registry_1.Step)("I expect element to be enabled", async (page) => {
|
|
57
|
+
exports.ExpectActiveEnabled = (0, registry_1.Step)("I expect element to be enabled", async (page) => {
|
|
32
58
|
const element = (0, state_1.getActiveElement)(page);
|
|
33
59
|
await (0, test_1.expect)(element).toBeEnabled();
|
|
34
60
|
console.log("✅ Element is enabled");
|
|
35
61
|
});
|
|
36
62
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
63
|
+
* Asserts that the currently stored (active) element is disabled.
|
|
64
|
+
* * @example
|
|
65
|
+
* ```gherkin
|
|
66
|
+
* Then I expect element to be disabled
|
|
67
|
+
* ```
|
|
39
68
|
*/
|
|
40
|
-
(0, registry_1.Step)("I expect element to be disabled", async (page) => {
|
|
69
|
+
exports.ExpectActiveDisabled = (0, registry_1.Step)("I expect element to be disabled", async (page) => {
|
|
41
70
|
const element = (0, state_1.getActiveElement)(page);
|
|
42
71
|
await (0, test_1.expect)(element).toBeDisabled();
|
|
43
72
|
console.log("✅ Element is disabled");
|
|
@@ -46,29 +75,39 @@ const state_1 = require("../utils/state");
|
|
|
46
75
|
// 2. TEXT & VALUE CHECKS
|
|
47
76
|
// ===============================
|
|
48
77
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
78
|
+
* Asserts that the currently stored (active) element has the exact text specified.
|
|
79
|
+
* * @example
|
|
80
|
+
* ```gherkin
|
|
81
|
+
* Then I expect element to have text "Submit Order"
|
|
82
|
+
* ```
|
|
51
83
|
*/
|
|
52
|
-
(0, registry_1.Step)("I expect element to have text {string}", async (page, text) => {
|
|
84
|
+
exports.ExpectActiveText = (0, registry_1.Step)("I expect element to have text {string}", async (page, text) => {
|
|
53
85
|
const element = (0, state_1.getActiveElement)(page);
|
|
54
86
|
await (0, test_1.expect)(element).toHaveText(text);
|
|
55
87
|
console.log(`✅ Element has text "${text}"`);
|
|
56
88
|
});
|
|
57
89
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
90
|
+
* Asserts that the currently stored (active) element contains the specified partial text.
|
|
91
|
+
* * @example
|
|
92
|
+
* ```gherkin
|
|
93
|
+
* Then I expect element to contain text "Order #"
|
|
94
|
+
* ```
|
|
60
95
|
*/
|
|
61
|
-
(0, registry_1.Step)("I expect element to contain text {string}", async (page, text) => {
|
|
96
|
+
exports.ExpectActiveContainText = (0, registry_1.Step)("I expect element to contain text {string}", async (page, text) => {
|
|
62
97
|
const element = (0, state_1.getActiveElement)(page);
|
|
63
98
|
await (0, test_1.expect)(element).toContainText(text);
|
|
64
99
|
console.log(`✅ Element contains text "${text}"`);
|
|
65
100
|
});
|
|
66
101
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
102
|
+
* Asserts that the currently stored (active) element (input/select) has a specific value.
|
|
103
|
+
* Supports aliases (e.g., `@orderId`) to compare against stored variables.
|
|
104
|
+
* * @example
|
|
105
|
+
* ```gherkin
|
|
106
|
+
* Then I expect element to have value "12345"
|
|
107
|
+
* Then I expect element to have value "@savedUserEmail"
|
|
108
|
+
* ```
|
|
69
109
|
*/
|
|
70
|
-
(0, registry_1.Step)("I expect element to have value {string}", async (page, value) => {
|
|
71
|
-
// Support aliases (e.g. @myVar)
|
|
110
|
+
exports.ExpectActiveValue = (0, registry_1.Step)("I expect element to have value {string}", async (page, value) => {
|
|
72
111
|
if (value.startsWith("@")) {
|
|
73
112
|
const alias = value.slice(1);
|
|
74
113
|
const stored = (0, state_1.getVariable)(page, alias);
|
|
@@ -84,40 +123,51 @@ const state_1 = require("../utils/state");
|
|
|
84
123
|
// 3. ATTRIBUTE CHECKS
|
|
85
124
|
// ===============================
|
|
86
125
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
126
|
+
* Asserts that the currently stored (active) element possesses a specific attribute.
|
|
127
|
+
* * @example
|
|
128
|
+
* ```gherkin
|
|
129
|
+
* Then I expect element to have attribute "required"
|
|
130
|
+
* ```
|
|
89
131
|
*/
|
|
90
|
-
(0, registry_1.Step)("I expect element to have attribute {string}", async (page, attr) => {
|
|
132
|
+
exports.ExpectActiveAttribute = (0, registry_1.Step)("I expect element to have attribute {string}", async (page, attr) => {
|
|
91
133
|
const element = (0, state_1.getActiveElement)(page);
|
|
92
134
|
await (0, test_1.expect)(element).toHaveAttribute(attr);
|
|
93
135
|
console.log(`✅ Element has attribute "${attr}"`);
|
|
94
136
|
});
|
|
95
137
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
138
|
+
* Asserts that the currently stored (active) element has an attribute with a specific value.
|
|
139
|
+
* * @example
|
|
140
|
+
* ```gherkin
|
|
141
|
+
* Then I expect element to have attribute "type" with value "password"
|
|
142
|
+
* ```
|
|
98
143
|
*/
|
|
99
|
-
(0, registry_1.Step)("I expect element to have attribute {string} with value {string}", async (page, attr, value) => {
|
|
144
|
+
exports.ExpectActiveAttributeValue = (0, registry_1.Step)("I expect element to have attribute {string} with value {string}", async (page, attr, value) => {
|
|
100
145
|
const element = (0, state_1.getActiveElement)(page);
|
|
101
146
|
await (0, test_1.expect)(element).toHaveAttribute(attr, value);
|
|
102
147
|
console.log(`✅ Element has attribute "${attr}" = "${value}"`);
|
|
103
148
|
});
|
|
104
149
|
// ===============================
|
|
105
|
-
// 4. VISUAL REGRESSION
|
|
150
|
+
// 4. VISUAL REGRESSION
|
|
106
151
|
// ===============================
|
|
107
152
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
153
|
+
* Performs a visual comparison of the entire page against a baseline screenshot.
|
|
154
|
+
* * @example
|
|
155
|
+
* ```gherkin
|
|
156
|
+
* Then I expect the page screenshot to match "landing-page.png"
|
|
157
|
+
* ```
|
|
111
158
|
*/
|
|
112
|
-
(0, registry_1.Step)("I expect the page screenshot to match {string}", async (page, filename) => {
|
|
159
|
+
exports.ExpectPageScreenshotMatch = (0, registry_1.Step)("I expect the page screenshot to match {string}", async (page, filename) => {
|
|
113
160
|
await (0, test_1.expect)(page).toHaveScreenshot(filename);
|
|
114
161
|
console.log(`📸 Page matches screenshot: ${filename}`);
|
|
115
162
|
});
|
|
116
163
|
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
164
|
+
* Performs a visual comparison of the active element against a baseline screenshot.
|
|
165
|
+
* * @example
|
|
166
|
+
* ```gherkin
|
|
167
|
+
* Then I expect the element screenshot to match "login-button.png"
|
|
168
|
+
* ```
|
|
119
169
|
*/
|
|
120
|
-
(0, registry_1.Step)("I expect the element screenshot to match {string}", async (page, filename) => {
|
|
170
|
+
exports.ExpectElementScreenshotMatch = (0, registry_1.Step)("I expect the element screenshot to match {string}", async (page, filename) => {
|
|
121
171
|
const element = (0, state_1.getActiveElement)(page);
|
|
122
172
|
await (0, test_1.expect)(element).toHaveScreenshot(filename);
|
|
123
173
|
console.log(`📸 Element matches screenshot: ${filename}`);
|