artes 1.7.25 → 1.7.26
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/README.md +781 -781
- package/assets/styles.css +4 -4
- package/cucumber.config.js +253 -253
- package/docs/ciExecutors.md +198 -198
- package/docs/emulationDevicesList.md +152 -152
- package/docs/functionDefinitions.md +2401 -2401
- package/docs/stepDefinitions.md +435 -435
- package/executer.js +266 -266
- package/index.js +51 -51
- package/package.json +56 -56
- package/src/helper/contextManager/browserManager.js +74 -74
- package/src/helper/contextManager/requestManager.js +23 -23
- package/src/helper/controller/elementController.js +35 -0
- package/src/helper/controller/findDuplicateTestNames.js +69 -69
- package/src/helper/controller/getEnvInfo.js +97 -97
- package/src/helper/controller/getExecutor.js +109 -109
- package/src/helper/controller/pomCollector.js +83 -83
- package/src/helper/controller/reportCustomizer.js +511 -511
- package/src/helper/controller/screenComparer.js +96 -96
- package/src/helper/controller/status-formatter.js +137 -137
- package/src/helper/controller/testCoverageCalculator.js +111 -111
- package/src/helper/executers/cleaner.js +23 -23
- package/src/helper/executers/exporter.js +19 -19
- package/src/helper/executers/helper.js +193 -193
- package/src/helper/executers/projectCreator.js +226 -226
- package/src/helper/executers/reportGenerator.js +91 -91
- package/src/helper/executers/testRunner.js +28 -28
- package/src/helper/executers/versionChecker.js +31 -31
- package/src/helper/imports/commons.js +69 -69
- package/src/helper/stepFunctions/APIActions.js +582 -582
- package/src/helper/stepFunctions/assertions.js +986 -986
- package/src/helper/stepFunctions/browserActions.js +87 -87
- package/src/helper/stepFunctions/elementInteractions.js +60 -60
- package/src/helper/stepFunctions/exporter.js +19 -19
- package/src/helper/stepFunctions/frameActions.js +72 -72
- package/src/helper/stepFunctions/keyboardActions.js +66 -66
- package/src/helper/stepFunctions/mouseActions.js +84 -84
- package/src/helper/stepFunctions/pageActions.js +43 -43
- package/src/hooks/context.js +18 -18
- package/src/hooks/hooks.js +287 -287
- package/src/stepDefinitions/API.steps.js +404 -404
- package/src/stepDefinitions/assertions.steps.js +1389 -1389
- package/src/stepDefinitions/browser.steps.js +74 -74
- package/src/stepDefinitions/frameActions.steps.js +132 -0
- package/src/stepDefinitions/keyboardActions.steps.js +264 -264
- package/src/stepDefinitions/mouseActions.steps.js +374 -374
- package/src/stepDefinitions/page.steps.js +71 -71
- package/src/stepDefinitions/random.steps.js +199 -199
- package/src/stepDefinitions/report.steps.js +5 -5
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
const { When, context } = require("../helper/imports/commons");
|
|
2
|
-
const { browser } = require("../helper/stepFunctions/exporter");
|
|
3
|
-
|
|
4
|
-
// User sets cookies in json format
|
|
5
|
-
When("User sets {string} cookies", async function (cookies) {
|
|
6
|
-
await browser.setCookies(cookies);
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
When("User checks accessibility of current page", async function () {
|
|
10
|
-
await browser.checkAccessibilityOfPage(context.page, null, null);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
When("User checks accessibility of {string} page", async function (url) {
|
|
14
|
-
await browser.checkAccessibilityOfPage(context.page, url, null);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
When("User checks accessibility of {string} element", async function (element) {
|
|
18
|
-
await browser.checkAccessibilityOfPage(context.page, null, element);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
When(
|
|
22
|
-
"User checks accessibility of {string} element on the {string} page",
|
|
23
|
-
async function (element, url) {
|
|
24
|
-
await browser.checkAccessibilityOfPage(context.page, url, element);
|
|
25
|
-
},
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
When(
|
|
29
|
-
"User checks accessibility of current page due to {string} WCAG",
|
|
30
|
-
async function (wcag) {
|
|
31
|
-
await browser.checkAccessibilityOfPageDueToWCAG(
|
|
32
|
-
context.page,
|
|
33
|
-
null,
|
|
34
|
-
null,
|
|
35
|
-
wcag,
|
|
36
|
-
);
|
|
37
|
-
},
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
When(
|
|
41
|
-
"User checks accessibility of {string} page due to {string} WCAG",
|
|
42
|
-
async function (url, wcag) {
|
|
43
|
-
await browser.checkAccessibilityOfPageDueToWCAG(
|
|
44
|
-
context.page,
|
|
45
|
-
url,
|
|
46
|
-
null,
|
|
47
|
-
wcag,
|
|
48
|
-
);
|
|
49
|
-
},
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
When(
|
|
53
|
-
"User checks accessibility of {string} element due to {string} WCAG",
|
|
54
|
-
async function (element, wcag) {
|
|
55
|
-
await browser.checkAccessibilityOfPageDueToWCAG(
|
|
56
|
-
context.page,
|
|
57
|
-
null,
|
|
58
|
-
element,
|
|
59
|
-
wcag,
|
|
60
|
-
);
|
|
61
|
-
},
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
When(
|
|
65
|
-
"User checks accessibility of {string} element on the {string} page due to {string} WCAG",
|
|
66
|
-
async function (element, url, wcag) {
|
|
67
|
-
await browser.checkAccessibilityOfPageDueToWCAG(
|
|
68
|
-
context.page,
|
|
69
|
-
url,
|
|
70
|
-
element,
|
|
71
|
-
wcag,
|
|
72
|
-
);
|
|
73
|
-
},
|
|
74
|
-
);
|
|
1
|
+
const { When, context } = require("../helper/imports/commons");
|
|
2
|
+
const { browser } = require("../helper/stepFunctions/exporter");
|
|
3
|
+
|
|
4
|
+
// User sets cookies in json format
|
|
5
|
+
When("User sets {string} cookies", async function (cookies) {
|
|
6
|
+
await browser.setCookies(cookies);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
When("User checks accessibility of current page", async function () {
|
|
10
|
+
await browser.checkAccessibilityOfPage(context.page, null, null);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
When("User checks accessibility of {string} page", async function (url) {
|
|
14
|
+
await browser.checkAccessibilityOfPage(context.page, url, null);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
When("User checks accessibility of {string} element", async function (element) {
|
|
18
|
+
await browser.checkAccessibilityOfPage(context.page, null, element);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
When(
|
|
22
|
+
"User checks accessibility of {string} element on the {string} page",
|
|
23
|
+
async function (element, url) {
|
|
24
|
+
await browser.checkAccessibilityOfPage(context.page, url, element);
|
|
25
|
+
},
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
When(
|
|
29
|
+
"User checks accessibility of current page due to {string} WCAG",
|
|
30
|
+
async function (wcag) {
|
|
31
|
+
await browser.checkAccessibilityOfPageDueToWCAG(
|
|
32
|
+
context.page,
|
|
33
|
+
null,
|
|
34
|
+
null,
|
|
35
|
+
wcag,
|
|
36
|
+
);
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
When(
|
|
41
|
+
"User checks accessibility of {string} page due to {string} WCAG",
|
|
42
|
+
async function (url, wcag) {
|
|
43
|
+
await browser.checkAccessibilityOfPageDueToWCAG(
|
|
44
|
+
context.page,
|
|
45
|
+
url,
|
|
46
|
+
null,
|
|
47
|
+
wcag,
|
|
48
|
+
);
|
|
49
|
+
},
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
When(
|
|
53
|
+
"User checks accessibility of {string} element due to {string} WCAG",
|
|
54
|
+
async function (element, wcag) {
|
|
55
|
+
await browser.checkAccessibilityOfPageDueToWCAG(
|
|
56
|
+
context.page,
|
|
57
|
+
null,
|
|
58
|
+
element,
|
|
59
|
+
wcag,
|
|
60
|
+
);
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
When(
|
|
65
|
+
"User checks accessibility of {string} element on the {string} page due to {string} WCAG",
|
|
66
|
+
async function (element, url, wcag) {
|
|
67
|
+
await browser.checkAccessibilityOfPageDueToWCAG(
|
|
68
|
+
context.page,
|
|
69
|
+
url,
|
|
70
|
+
element,
|
|
71
|
+
wcag,
|
|
72
|
+
);
|
|
73
|
+
},
|
|
74
|
+
);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { When } = require("../helper/imports/commons");
|
|
2
2
|
const { frame } = require("../helper/stepFunctions/exporter");
|
|
3
|
+
const { saveVar, element} = require("artes");
|
|
3
4
|
|
|
4
5
|
// User takes a screenshot of a specific selector
|
|
5
6
|
When("User takes a screenshot of {string}", async function (selector) {
|
|
@@ -74,3 +75,134 @@ When("User gets the element with role {string}", async function (role) {
|
|
|
74
75
|
When("User gets the element with testId {string}", async function (testId) {
|
|
75
76
|
await frame.getByTestId(testId);
|
|
76
77
|
});
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
When("User saves the value of {string} as {string}", async function (selector, varName) {
|
|
83
|
+
|
|
84
|
+
async function extractElementValue(locator) {
|
|
85
|
+
await locator.waitFor({ state: "visible" });
|
|
86
|
+
|
|
87
|
+
const tagName = await locator.evaluate((el) => el.tagName.toLowerCase());
|
|
88
|
+
const normalize = (str) => str?.replace(/\s+/g, " ").trim();
|
|
89
|
+
|
|
90
|
+
if (["input", "textarea"].includes(tagName)) {
|
|
91
|
+
return normalize(await locator.inputValue());
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (tagName === "select") {
|
|
95
|
+
return normalize(
|
|
96
|
+
await locator.evaluate((el) => el.options[el.selectedIndex]?.text)
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (tagName === "img") {
|
|
101
|
+
return normalize(await locator.getAttribute("alt"));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Try several strategies in order, use the first non-empty result
|
|
105
|
+
const strategies = [
|
|
106
|
+
() => locator.innerText(),
|
|
107
|
+
() => locator.textContent(),
|
|
108
|
+
() => locator.getAttribute("value"),
|
|
109
|
+
() => locator.getAttribute("aria-label"),
|
|
110
|
+
() => locator.getAttribute("title"),
|
|
111
|
+
() => locator.getAttribute("placeholder"),
|
|
112
|
+
() => locator.getAttribute("alt"),
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
for (const strategy of strategies) {
|
|
116
|
+
try {
|
|
117
|
+
const result = normalize(await strategy());
|
|
118
|
+
if (result) return result;
|
|
119
|
+
} catch {
|
|
120
|
+
// strategy not applicable to this element, try next
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return "";
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const locator = element(selector);
|
|
129
|
+
const value = await extractElementValue(locator);
|
|
130
|
+
console.log( typeof locator)
|
|
131
|
+
|
|
132
|
+
saveVar(value, varName);
|
|
133
|
+
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
When(
|
|
138
|
+
"User saves the value of {int} th of {string} as {string}",
|
|
139
|
+
async function (ordinal, selector, varName) {
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
async function extractElementValue(locator) {
|
|
143
|
+
await locator.waitFor({ state: "visible" });
|
|
144
|
+
|
|
145
|
+
const tagName = await locator.evaluate((el) => el.tagName.toLowerCase());
|
|
146
|
+
const normalize = (str) => str?.replace(/\s+/g, " ").trim();
|
|
147
|
+
|
|
148
|
+
if (["input", "textarea"].includes(tagName)) {
|
|
149
|
+
return normalize(await locator.inputValue());
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (tagName === "select") {
|
|
153
|
+
return normalize(
|
|
154
|
+
await locator.evaluate((el) => el.options[el.selectedIndex]?.text)
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (tagName === "img") {
|
|
159
|
+
return normalize(await locator.getAttribute("alt"));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const strategies = [
|
|
163
|
+
() => locator.innerText(),
|
|
164
|
+
() => locator.textContent(),
|
|
165
|
+
() => locator.getAttribute("value"),
|
|
166
|
+
() => locator.getAttribute("aria-label"),
|
|
167
|
+
() => locator.getAttribute("title"),
|
|
168
|
+
() => locator.getAttribute("placeholder"),
|
|
169
|
+
() => locator.getAttribute("alt"),
|
|
170
|
+
];
|
|
171
|
+
|
|
172
|
+
for (const strategy of strategies) {
|
|
173
|
+
try {
|
|
174
|
+
const result = normalize(await strategy());
|
|
175
|
+
if (result) return result;
|
|
176
|
+
} catch {
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return "";
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function ordinalToIndex(ordinal) {
|
|
185
|
+
const num = parseInt(ordinal, 10);
|
|
186
|
+
if (isNaN(num) || num < 1) {
|
|
187
|
+
throw new Error(`Invalid ordinal "${ordinal}" — must be like "1st", "2nd", "3rd", "4th"...`);
|
|
188
|
+
}
|
|
189
|
+
return num - 1;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
const index = ordinalToIndex(ordinal);
|
|
194
|
+
const baseLocator = element(selector);
|
|
195
|
+
|
|
196
|
+
const count = await baseLocator.count();
|
|
197
|
+
if (index >= count) {
|
|
198
|
+
throw new Error(
|
|
199
|
+
`Requested ${ordinal} match for "${selector}", but only ${count} element(s) found.`
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const locator = baseLocator.nth(index);
|
|
204
|
+
const value = await extractElementValue(locator);
|
|
205
|
+
|
|
206
|
+
saveVar(value, varName);
|
|
207
|
+
}
|
|
208
|
+
);
|