browserstack-cypress-cli 1.28.1 → 1.29.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/CODEOWNERS +1 -1
- package/bin/accessibility-automation/cypress/index.js +352 -109
- package/bin/accessibility-automation/helper.js +5 -2
- package/bin/accessibility-automation/plugin/index.js +11 -1
- package/bin/commands/runs.js +3 -3
- package/bin/helpers/capabilityHelper.js +20 -3
- package/bin/helpers/utils.js +1 -0
- package/package.json +1 -1
package/CODEOWNERS
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
* @browserstack/
|
|
1
|
+
* @browserstack/automate-dev
|
|
@@ -1,114 +1,361 @@
|
|
|
1
1
|
/* Event listeners + custom commands for Cypress */
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
const browserStackLog = (message) => {
|
|
4
|
+
if (!Cypress.env('BROWSERSTACK_LOGS')) return;
|
|
5
|
+
cy.task('browserstack_log', message);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const commandsToWrap = ['visit', 'click', 'type', 'request', 'dblclick', 'rightclick', 'clear', 'check', 'uncheck', 'select', 'trigger', 'selectFile', 'scrollIntoView', 'scroll', 'scrollTo', 'blur', 'focus', 'go', 'reload', 'submit', 'viewport', 'origin'];
|
|
9
|
+
|
|
10
|
+
const performScan = (win, payloadToSend) =>
|
|
11
|
+
new Promise(async (resolve, reject) => {
|
|
12
|
+
const isHttpOrHttps = /^(http|https):$/.test(win.location.protocol);
|
|
13
|
+
if (!isHttpOrHttps) {
|
|
14
|
+
resolve();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function findAccessibilityAutomationElement() {
|
|
18
|
+
return win.document.querySelector("#accessibility-automation-element");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function waitForScannerReadiness(retryCount = 30, retryInterval = 100) {
|
|
22
|
+
return new Promise(async (resolve, reject) => {
|
|
23
|
+
let count = 0;
|
|
24
|
+
const intervalID = setInterval(async () => {
|
|
25
|
+
if (count > retryCount) {
|
|
26
|
+
clearInterval(intervalID);
|
|
27
|
+
reject(
|
|
28
|
+
new Error(
|
|
29
|
+
"Accessibility Automation Scanner is not ready on the page."
|
|
30
|
+
)
|
|
31
|
+
);
|
|
32
|
+
} else if (findAccessibilityAutomationElement()) {
|
|
33
|
+
clearInterval(intervalID);
|
|
34
|
+
resolve("Scanner set");
|
|
35
|
+
} else {
|
|
36
|
+
count += 1;
|
|
37
|
+
}
|
|
38
|
+
}, retryInterval);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function startScan() {
|
|
43
|
+
function onScanComplete() {
|
|
44
|
+
win.removeEventListener("A11Y_SCAN_FINISHED", onScanComplete);
|
|
45
|
+
resolve();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
win.addEventListener("A11Y_SCAN_FINISHED", onScanComplete);
|
|
49
|
+
const e = new CustomEvent("A11Y_SCAN", { detail: payloadToSend });
|
|
50
|
+
win.dispatchEvent(e);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (findAccessibilityAutomationElement()) {
|
|
54
|
+
startScan();
|
|
55
|
+
} else {
|
|
56
|
+
waitForScannerReadiness()
|
|
57
|
+
.then(startScan)
|
|
58
|
+
.catch(async (err) => {
|
|
59
|
+
resolve("Scanner is not ready on the page after multiple retries. performscan");
|
|
12
60
|
});
|
|
13
|
-
const e = new CustomEvent('A11Y_FORCE_START');
|
|
14
|
-
window.parent.dispatchEvent(e);
|
|
15
|
-
})
|
|
16
61
|
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
});
|
|
62
|
+
})
|
|
20
63
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
64
|
+
const getAccessibilityResultsSummary = (win) =>
|
|
65
|
+
new Promise((resolve) => {
|
|
66
|
+
const isHttpOrHttps = /^(http|https):$/.test(window.location.protocol);
|
|
67
|
+
if (!isHttpOrHttps) {
|
|
68
|
+
resolve();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function findAccessibilityAutomationElement() {
|
|
72
|
+
return win.document.querySelector("#accessibility-automation-element");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function waitForScannerReadiness(retryCount = 30, retryInterval = 100) {
|
|
76
|
+
return new Promise((resolve, reject) => {
|
|
77
|
+
let count = 0;
|
|
78
|
+
const intervalID = setInterval(() => {
|
|
79
|
+
if (count > retryCount) {
|
|
80
|
+
clearInterval(intervalID);
|
|
81
|
+
reject(
|
|
82
|
+
new Error(
|
|
83
|
+
"Accessibility Automation Scanner is not ready on the page."
|
|
84
|
+
)
|
|
85
|
+
);
|
|
86
|
+
} else if (findAccessibilityAutomationElement()) {
|
|
87
|
+
clearInterval(intervalID);
|
|
88
|
+
resolve("Scanner set");
|
|
89
|
+
} else {
|
|
90
|
+
count += 1;
|
|
36
91
|
}
|
|
37
|
-
|
|
38
|
-
|
|
92
|
+
}, retryInterval);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function getSummary() {
|
|
97
|
+
function onReceiveSummary(event) {
|
|
98
|
+
|
|
99
|
+
win.removeEventListener("A11Y_RESULTS_SUMMARY", onReceiveSummary);
|
|
100
|
+
resolve(event.detail);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
win.addEventListener("A11Y_RESULTS_SUMMARY", onReceiveSummary);
|
|
104
|
+
const e = new CustomEvent("A11Y_GET_RESULTS_SUMMARY");
|
|
105
|
+
win.dispatchEvent(e);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (findAccessibilityAutomationElement()) {
|
|
109
|
+
getSummary();
|
|
110
|
+
} else {
|
|
111
|
+
waitForScannerReadiness()
|
|
112
|
+
.then(getSummary)
|
|
113
|
+
.catch((err) => {
|
|
114
|
+
resolve();
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
const getAccessibilityResults = (win) =>
|
|
120
|
+
new Promise((resolve) => {
|
|
121
|
+
const isHttpOrHttps = /^(http|https):$/.test(window.location.protocol);
|
|
122
|
+
if (!isHttpOrHttps) {
|
|
123
|
+
resolve();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function findAccessibilityAutomationElement() {
|
|
127
|
+
return win.document.querySelector("#accessibility-automation-element");
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function waitForScannerReadiness(retryCount = 30, retryInterval = 100) {
|
|
131
|
+
return new Promise((resolve, reject) => {
|
|
132
|
+
let count = 0;
|
|
133
|
+
const intervalID = setInterval(() => {
|
|
134
|
+
if (count > retryCount) {
|
|
135
|
+
clearInterval(intervalID);
|
|
136
|
+
reject(
|
|
137
|
+
new Error(
|
|
138
|
+
"Accessibility Automation Scanner is not ready on the page."
|
|
139
|
+
)
|
|
140
|
+
);
|
|
141
|
+
} else if (findAccessibilityAutomationElement()) {
|
|
142
|
+
clearInterval(intervalID);
|
|
143
|
+
resolve("Scanner set");
|
|
144
|
+
} else {
|
|
145
|
+
count += 1;
|
|
39
146
|
}
|
|
147
|
+
}, retryInterval);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
40
150
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
151
|
+
function getResults() {
|
|
152
|
+
function onReceivedResult(event) {
|
|
153
|
+
win.removeEventListener("A11Y_RESULTS_RESPONSE", onReceivedResult);
|
|
154
|
+
resolve(event.detail);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
win.addEventListener("A11Y_RESULTS_RESPONSE", onReceivedResult);
|
|
158
|
+
const e = new CustomEvent("A11Y_GET_RESULTS");
|
|
159
|
+
win.dispatchEvent(e);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (findAccessibilityAutomationElement()) {
|
|
163
|
+
getResults();
|
|
164
|
+
} else {
|
|
165
|
+
waitForScannerReadiness()
|
|
166
|
+
.then(getResults)
|
|
167
|
+
.catch((err) => {
|
|
168
|
+
resolve();
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
const saveTestResults = (win, payloadToSend) =>
|
|
174
|
+
new Promise( (resolve, reject) => {
|
|
175
|
+
try {
|
|
176
|
+
const isHttpOrHttps = /^(http|https):$/.test(win.location.protocol);
|
|
177
|
+
if (!isHttpOrHttps) {
|
|
178
|
+
resolve("Unable to save accessibility results, Invalid URL.");
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function findAccessibilityAutomationElement() {
|
|
182
|
+
return win.document.querySelector("#accessibility-automation-element");
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function waitForScannerReadiness(retryCount = 30, retryInterval = 100) {
|
|
186
|
+
return new Promise((resolve, reject) => {
|
|
187
|
+
let count = 0;
|
|
188
|
+
const intervalID = setInterval(async () => {
|
|
189
|
+
if (count > retryCount) {
|
|
190
|
+
clearInterval(intervalID);
|
|
191
|
+
reject(
|
|
192
|
+
new Error(
|
|
193
|
+
"Accessibility Automation Scanner is not ready on the page."
|
|
194
|
+
)
|
|
195
|
+
);
|
|
196
|
+
} else if (findAccessibilityAutomationElement()) {
|
|
197
|
+
clearInterval(intervalID);
|
|
198
|
+
resolve("Scanner set");
|
|
199
|
+
} else {
|
|
200
|
+
count += 1;
|
|
201
|
+
}
|
|
202
|
+
}, retryInterval);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function saveResults() {
|
|
207
|
+
function onResultsSaved(event) {
|
|
208
|
+
resolve();
|
|
47
209
|
}
|
|
210
|
+
win.addEventListener("A11Y_RESULTS_SAVED", onResultsSaved);
|
|
211
|
+
const e = new CustomEvent("A11Y_SAVE_RESULTS", {
|
|
212
|
+
detail: payloadToSend,
|
|
213
|
+
});
|
|
214
|
+
win.dispatchEvent(e);
|
|
48
215
|
}
|
|
49
|
-
|
|
50
|
-
if (
|
|
51
|
-
|
|
216
|
+
|
|
217
|
+
if (findAccessibilityAutomationElement()) {
|
|
218
|
+
saveResults();
|
|
52
219
|
} else {
|
|
53
|
-
|
|
220
|
+
waitForScannerReadiness()
|
|
221
|
+
.then(saveResults)
|
|
222
|
+
.catch(async (err) => {
|
|
223
|
+
resolve("Scanner is not ready on the page after multiple retries. after run");
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
} catch(er) {
|
|
228
|
+
resolve()
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
const shouldScanForAccessibility = (attributes) => {
|
|
234
|
+
if (Cypress.env("IS_ACCESSIBILITY_EXTENSION_LOADED") !== "true") return false;
|
|
235
|
+
|
|
236
|
+
const extensionPath = Cypress.env("ACCESSIBILITY_EXTENSION_PATH");
|
|
237
|
+
const isHeaded = Cypress.browser.isHeaded;
|
|
238
|
+
|
|
239
|
+
if (!isHeaded || (extensionPath === undefined)) return false;
|
|
240
|
+
|
|
241
|
+
let shouldScanTestForAccessibility = true;
|
|
242
|
+
|
|
243
|
+
if (Cypress.env("INCLUDE_TAGS_FOR_ACCESSIBILITY") || Cypress.env("EXCLUDE_TAGS_FOR_ACCESSIBILITY")) {
|
|
244
|
+
try {
|
|
245
|
+
let includeTagArray = [];
|
|
246
|
+
let excludeTagArray = [];
|
|
247
|
+
if (Cypress.env("INCLUDE_TAGS_FOR_ACCESSIBILITY")) {
|
|
248
|
+
includeTagArray = Cypress.env("INCLUDE_TAGS_FOR_ACCESSIBILITY").split(";")
|
|
54
249
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
filePath = attributes.invocationDetails.relativeFile;
|
|
250
|
+
if (Cypress.env("EXCLUDE_TAGS_FOR_ACCESSIBILITY")) {
|
|
251
|
+
excludeTagArray = Cypress.env("EXCLUDE_TAGS_FOR_ACCESSIBILITY").split(";")
|
|
58
252
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
253
|
+
|
|
254
|
+
const fullTestName = attributes.title;
|
|
255
|
+
const excluded = excludeTagArray.some((exclude) => fullTestName.includes(exclude));
|
|
256
|
+
const included = includeTagArray.length === 0 || includeTags.some((include) => fullTestName.includes(include));
|
|
257
|
+
shouldScanTestForAccessibility = !excluded && included;
|
|
258
|
+
} catch (error) {
|
|
259
|
+
browserStackLog("Error while validating test case for accessibility before scanning. Error : ", error);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return shouldScanTestForAccessibility;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
Cypress.on('command:start', async (command) => {
|
|
267
|
+
if(!command || !command.attributes) return;
|
|
268
|
+
if(command.attributes.name == 'window' || command.attributes.name == 'then' || command.attributes.name == 'wrap') {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (!commandsToWrap.includes(command.attributes.name)) return;
|
|
273
|
+
|
|
274
|
+
const attributes = Cypress.mocha.getRunner().suite.ctx.currentTest || Cypress.mocha.getRunner().suite.ctx._runnable;
|
|
275
|
+
|
|
276
|
+
let shouldScanTestForAccessibility = shouldScanForAccessibility(attributes);
|
|
277
|
+
if (!shouldScanTestForAccessibility) return;
|
|
278
|
+
|
|
279
|
+
cy.window().then((win) => {
|
|
280
|
+
browserStackLog('Performing scan form command ' + command.attributes.name);
|
|
281
|
+
cy.wrap(performScan(win, {method: command.attributes.name}), {timeout: 30000});
|
|
282
|
+
})
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
afterEach(() => {
|
|
286
|
+
const attributes = Cypress.mocha.getRunner().suite.ctx.currentTest;
|
|
287
|
+
cy.window().then(async (win) => {
|
|
288
|
+
let shouldScanTestForAccessibility = shouldScanForAccessibility(attributes);
|
|
289
|
+
if (!shouldScanTestForAccessibility) return cy.wrap({});
|
|
290
|
+
|
|
291
|
+
cy.wrap(performScan(win), {timeout: 30000}).then(() => {
|
|
292
|
+
try {
|
|
293
|
+
let os_data;
|
|
294
|
+
if (Cypress.env("OS")) {
|
|
295
|
+
os_data = Cypress.env("OS");
|
|
296
|
+
} else {
|
|
297
|
+
os_data = Cypress.platform === 'linux' ? 'mac' : "win"
|
|
75
298
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
window.parent.addEventListener('A11Y_TAP_TRANSPORTER', (event) => {
|
|
80
|
-
resolve(event.detail);
|
|
81
|
-
});
|
|
299
|
+
let filePath = '';
|
|
300
|
+
if (attributes.invocationDetails !== undefined && attributes.invocationDetails.relativeFile !== undefined) {
|
|
301
|
+
filePath = attributes.invocationDetails.relativeFile;
|
|
82
302
|
}
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
303
|
+
const payloadToSend = {
|
|
304
|
+
"saveResults": shouldScanTestForAccessibility,
|
|
305
|
+
"testDetails": {
|
|
306
|
+
"name": attributes.title,
|
|
307
|
+
"testRunId": '5058', // variable not consumed, shouldn't matter what we send
|
|
308
|
+
"filePath": filePath,
|
|
309
|
+
"scopeList": [
|
|
310
|
+
filePath,
|
|
311
|
+
attributes.title
|
|
312
|
+
]
|
|
313
|
+
},
|
|
314
|
+
"platform": {
|
|
315
|
+
"os_name": os_data,
|
|
316
|
+
"os_version": Cypress.env("OS_VERSION"),
|
|
317
|
+
"browser_name": Cypress.browser.name,
|
|
318
|
+
"browser_version": Cypress.browser.version
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
browserStackLog(`Saving accessibility test results`);
|
|
322
|
+
cy.wrap(saveTestResults(win, payloadToSend), {timeout: 30000}).then(() => {
|
|
323
|
+
browserStackLog(`Saved accessibility test results`);
|
|
324
|
+
})
|
|
89
325
|
|
|
326
|
+
} catch (er) {
|
|
327
|
+
}
|
|
328
|
+
})
|
|
329
|
+
});
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
Cypress.Commands.add('performScan', () => {
|
|
333
|
+
try {
|
|
334
|
+
const attributes = Cypress.mocha.getRunner().suite.ctx.currentTest || Cypress.mocha.getRunner().suite.ctx._runnable;
|
|
335
|
+
const shouldScanTestForAccessibility = shouldScanForAccessibility(attributes);
|
|
336
|
+
if (!shouldScanTestForAccessibility) {
|
|
337
|
+
browserStackLog(`Not a Accessibility Automation session, cannot perform scan.`);
|
|
338
|
+
return cy.wrap({});
|
|
339
|
+
}
|
|
340
|
+
cy.window().then(async (win) => {
|
|
341
|
+
browserStackLog(`Performing accessibility scan`);
|
|
342
|
+
await performScan(win);
|
|
343
|
+
});
|
|
90
344
|
} catch {}
|
|
91
|
-
})
|
|
345
|
+
})
|
|
92
346
|
|
|
93
347
|
Cypress.Commands.add('getAccessibilityResultsSummary', () => {
|
|
94
348
|
try {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
};
|
|
106
|
-
window.parent.addEventListener('A11Y_RESULTS_SUMMARY_RESPONSE', fn);
|
|
107
|
-
window.parent.dispatchEvent(e);
|
|
108
|
-
} catch (err) {
|
|
109
|
-
console.log("No accessibility results summary was found.");
|
|
110
|
-
reject(err);
|
|
111
|
-
}
|
|
349
|
+
const attributes = Cypress.mocha.getRunner().suite.ctx.currentTest || Cypress.mocha.getRunner().suite.ctx._runnable;
|
|
350
|
+
const shouldScanTestForAccessibility = shouldScanForAccessibility(attributes);
|
|
351
|
+
if (!shouldScanTestForAccessibility) {
|
|
352
|
+
browserStackLog(`Not a Accessibility Automation session, cannot retrieve Accessibility results summary.`);
|
|
353
|
+
return cy.wrap({});
|
|
354
|
+
}
|
|
355
|
+
cy.window().then(async (win) => {
|
|
356
|
+
await performScan(win);
|
|
357
|
+
browserStackLog('Getting accessibility results summary');
|
|
358
|
+
return await getAccessibilityResultsSummary(win);
|
|
112
359
|
});
|
|
113
360
|
} catch {}
|
|
114
361
|
|
|
@@ -116,25 +363,21 @@ Cypress.Commands.add('getAccessibilityResultsSummary', () => {
|
|
|
116
363
|
|
|
117
364
|
Cypress.Commands.add('getAccessibilityResults', () => {
|
|
118
365
|
try {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
} catch (err) {
|
|
133
|
-
console.log("No accessibility results were found.");
|
|
134
|
-
reject(err);
|
|
135
|
-
}
|
|
366
|
+
const attributes = Cypress.mocha.getRunner().suite.ctx.currentTest || Cypress.mocha.getRunner().suite.ctx._runnable;
|
|
367
|
+
const shouldScanTestForAccessibility = shouldScanForAccessibility(attributes);
|
|
368
|
+
if (!shouldScanTestForAccessibility) {
|
|
369
|
+
browserStackLog(`Not a Accessibility Automation session, cannot retrieve Accessibility results.`);
|
|
370
|
+
return cy.wrap({});
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/* browserstack_accessibility_automation_script */
|
|
374
|
+
|
|
375
|
+
cy.window().then(async (win) => {
|
|
376
|
+
await performScan(win);
|
|
377
|
+
browserStackLog('Getting accessibility results');
|
|
378
|
+
return await getAccessibilityResults(win);
|
|
136
379
|
});
|
|
380
|
+
|
|
137
381
|
} catch {}
|
|
138
382
|
|
|
139
383
|
});
|
|
140
|
-
|
|
@@ -66,7 +66,10 @@ exports.createAccessibilityTestRun = async (user_config, framework) => {
|
|
|
66
66
|
'source': {
|
|
67
67
|
frameworkName: "Cypress",
|
|
68
68
|
frameworkVersion: helper.getPackageVersion('cypress', user_config),
|
|
69
|
-
sdkVersion: helper.getAgentVersion()
|
|
69
|
+
sdkVersion: helper.getAgentVersion(),
|
|
70
|
+
language: 'javascript',
|
|
71
|
+
testFramework: 'cypress',
|
|
72
|
+
testFrameworkVersion: helper.getPackageVersion('cypress', user_config)
|
|
70
73
|
},
|
|
71
74
|
'settings': settings,
|
|
72
75
|
'versionControl': await helper.getGitMetaData(),
|
|
@@ -92,7 +95,7 @@ exports.createAccessibilityTestRun = async (user_config, framework) => {
|
|
|
92
95
|
};
|
|
93
96
|
|
|
94
97
|
const response = await nodeRequest(
|
|
95
|
-
'POST', 'test_runs', data, config, API_URL
|
|
98
|
+
'POST', 'v2/test_runs', data, config, API_URL
|
|
96
99
|
);
|
|
97
100
|
if(!utils.isUndefined(response.data)) {
|
|
98
101
|
process.env.BS_A11Y_JWT = response.data.data.accessibilityToken;
|
|
@@ -3,9 +3,19 @@ const path = require("node:path");
|
|
|
3
3
|
|
|
4
4
|
const browserstackAccessibility = (on, config) => {
|
|
5
5
|
let browser_validation = true;
|
|
6
|
+
if (process.env.BROWSERSTACK_ACCESSIBILITY_DEBUG === 'true') {
|
|
7
|
+
config.env.BROWSERSTACK_LOGS = 'true';
|
|
8
|
+
process.env.BROWSERSTACK_LOGS = 'true';
|
|
9
|
+
}
|
|
10
|
+
on('task', {
|
|
11
|
+
browserstack_log(message) {
|
|
12
|
+
console.log(message)
|
|
13
|
+
|
|
14
|
+
return null
|
|
15
|
+
},
|
|
16
|
+
})
|
|
6
17
|
on('before:browser:launch', (browser = {}, launchOptions) => {
|
|
7
18
|
try {
|
|
8
|
-
|
|
9
19
|
if (process.env.ACCESSIBILITY_EXTENSION_PATH !== undefined) {
|
|
10
20
|
if (browser.name !== 'chrome') {
|
|
11
21
|
console.log(`Accessibility Automation will run only on Chrome browsers.`);
|
package/bin/commands/runs.js
CHANGED
|
@@ -61,6 +61,9 @@ module.exports = function run(args, rawArgs) {
|
|
|
61
61
|
markBlockStart('setConfig');
|
|
62
62
|
logger.debug('Started setting the configs');
|
|
63
63
|
|
|
64
|
+
// set cypress config filename
|
|
65
|
+
utils.setCypressConfigFilename(bsConfig, args);
|
|
66
|
+
|
|
64
67
|
/*
|
|
65
68
|
Set testObservability & browserstackAutomation flags
|
|
66
69
|
*/
|
|
@@ -85,9 +88,6 @@ module.exports = function run(args, rawArgs) {
|
|
|
85
88
|
// accept the build name from command line if provided
|
|
86
89
|
utils.setBuildName(bsConfig, args);
|
|
87
90
|
|
|
88
|
-
// set cypress config filename
|
|
89
|
-
utils.setCypressConfigFilename(bsConfig, args);
|
|
90
|
-
|
|
91
91
|
if(isBrowserstackInfra) {
|
|
92
92
|
// set cypress test suite type
|
|
93
93
|
utils.setCypressTestSuiteType(bsConfig);
|
|
@@ -122,6 +122,8 @@ const caps = (bsConfig, zip) => {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
if (process.env.BROWSERSTACK_TEST_ACCESSIBILITY === 'true') {
|
|
125
|
+
// If any of the platform has accessibility true, make it true
|
|
126
|
+
bsConfig.run_settings["accessibility"] = true;
|
|
125
127
|
bsConfig.run_settings["accessibilityPlatforms"] = getAccessibilityPlatforms(bsConfig);
|
|
126
128
|
}
|
|
127
129
|
|
|
@@ -147,14 +149,29 @@ const caps = (bsConfig, zip) => {
|
|
|
147
149
|
})
|
|
148
150
|
}
|
|
149
151
|
const getAccessibilityPlatforms = (bsConfig) => {
|
|
150
|
-
const browserList =
|
|
152
|
+
const browserList = [];
|
|
153
|
+
if (bsConfig.browsers) {
|
|
154
|
+
bsConfig.browsers.forEach((element) => {
|
|
155
|
+
element.versions.forEach((version) => {
|
|
156
|
+
browserList.push({...element, version, platform: element.os + "-" + element.browser});
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
151
161
|
const accessibilityPlatforms = Array(browserList.length).fill(false);
|
|
152
162
|
let rootLevelAccessibility = false;
|
|
153
163
|
if (!Utils.isUndefined(bsConfig.run_settings.accessibility)) {
|
|
154
|
-
rootLevelAccessibility = bsConfig.run_settings.accessibility.toString() === 'true'
|
|
164
|
+
rootLevelAccessibility = bsConfig.run_settings.accessibility.toString() === 'true';
|
|
155
165
|
}
|
|
156
166
|
browserList.forEach((browserDetails, idx) => {
|
|
157
|
-
accessibilityPlatforms[idx] = (browserDetails.accessibility === undefined) ? rootLevelAccessibility : browserDetails.accessibility
|
|
167
|
+
accessibilityPlatforms[idx] = (browserDetails.accessibility === undefined) ? rootLevelAccessibility : browserDetails.accessibility;
|
|
168
|
+
if (Utils.isUndefined(bsConfig.run_settings.headless) || !(String(bsConfig.run_settings.headless) === "false")) {
|
|
169
|
+
logger.warn(`Accessibility Automation will not run on legacy headless mode. Switch to new headless mode or avoid using headless mode for ${browserDetails.platform}.`);
|
|
170
|
+
} else if (browserDetails.browser && browserDetails.browser.toLowerCase() !== 'chrome') {
|
|
171
|
+
logger.warn(`Accessibility Automation will run only on Chrome browsers for ${browserDetails.platform}.`);
|
|
172
|
+
} else if (browserDetails.version && !browserDetails.version.includes('latest') && browserDetails.version <= 94) {
|
|
173
|
+
logger.warn(`Accessibility Automation will run only on Chrome browser version greater than 94 for ${browserDetails.platform}.`);
|
|
174
|
+
}
|
|
158
175
|
});
|
|
159
176
|
return accessibilityPlatforms;
|
|
160
177
|
}
|
package/bin/helpers/utils.js
CHANGED
|
@@ -561,6 +561,7 @@ exports.setSystemEnvs = (bsConfig) => {
|
|
|
561
561
|
|
|
562
562
|
try {
|
|
563
563
|
const accessibilityOptions = bsConfig.run_settings.accessibilityOptions;
|
|
564
|
+
envKeys['BROWSERSTACK_ACCESSIBILITY_DEBUG'] = process.env.BROWSERSTACK_ACCESSIBILITY_DEBUG;
|
|
564
565
|
if (accessibilityOptions) {
|
|
565
566
|
Object.keys(accessibilityOptions).forEach(key => {
|
|
566
567
|
const a11y_env_key = `ACCESSIBILITY_${key.toUpperCase()}`
|