browserstack-cypress-cli 1.31.10 → 1.32.1
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/bin/accessibility-automation/cypress/index.js +274 -276
- package/bin/accessibility-automation/helper.js +41 -27
- package/bin/accessibility-automation/plugin/index.js +2 -3
- package/bin/commands/generateReport.js +0 -1
- package/bin/commands/info.js +39 -38
- package/bin/commands/runs.js +7 -14
- package/bin/commands/stop.js +0 -1
- package/bin/helpers/atsHelper.js +48 -39
- package/bin/helpers/build.js +39 -31
- package/bin/helpers/buildArtifacts.js +87 -69
- package/bin/helpers/capabilityHelper.js +1 -0
- package/bin/helpers/checkUploaded.js +43 -33
- package/bin/helpers/downloadBuildStacktrace.js +23 -14
- package/bin/helpers/getInitialDetails.js +33 -22
- package/bin/helpers/helper.js +10 -2
- package/bin/helpers/reporterHTML.js +52 -39
- package/bin/helpers/sync/syncSpecsLogs.js +36 -23
- package/bin/helpers/usageReporting.js +52 -34
- package/bin/helpers/utils.js +96 -77
- package/bin/helpers/zipUpload.js +61 -85
- package/bin/testObservability/crashReporter/index.js +23 -14
- package/bin/testObservability/cypress/index.js +7 -7
- package/bin/testObservability/helper/helper.js +59 -43
- package/bin/testObservability/helper/requestQueueHandler.js +2 -2
- package/bin/testObservability/plugin/ipcServer.js +6 -6
- package/bin/testObservability/reporter/index.js +8 -10
- package/package.json +5 -4
|
@@ -1,383 +1,381 @@
|
|
|
1
1
|
/* Event listeners + custom commands for Cypress */
|
|
2
2
|
|
|
3
3
|
const browserStackLog = (message) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
4
|
+
if (!Cypress.env('BROWSERSTACK_LOGS')) return;
|
|
5
|
+
cy.task('browserstack_log', message);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
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
9
|
|
|
10
10
|
const performScan = (win, payloadToSend) =>
|
|
11
|
-
|
|
11
|
+
new Promise(async (resolve, reject) => {
|
|
12
12
|
const isHttpOrHttps = /^(http|https):$/.test(win.location.protocol);
|
|
13
13
|
if (!isHttpOrHttps) {
|
|
14
|
-
|
|
14
|
+
resolve();
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
function findAccessibilityAutomationElement() {
|
|
18
|
-
|
|
18
|
+
return win.document.querySelector("#accessibility-automation-element");
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
function waitForScannerReadiness(retryCount = 30, retryInterval = 100) {
|
|
22
|
-
|
|
22
|
+
return new Promise(async (resolve, reject) => {
|
|
23
23
|
let count = 0;
|
|
24
24
|
const intervalID = setInterval(async () => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
38
|
}, retryInterval);
|
|
39
|
-
|
|
39
|
+
});
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
function startScan() {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
function onScanComplete() {
|
|
44
|
+
win.removeEventListener("A11Y_SCAN_FINISHED", onScanComplete);
|
|
45
|
+
resolve();
|
|
46
|
+
}
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
win.addEventListener("A11Y_SCAN_FINISHED", onScanComplete);
|
|
49
|
+
const e = new CustomEvent("A11Y_SCAN", { detail: payloadToSend });
|
|
50
|
+
win.dispatchEvent(e);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
if (findAccessibilityAutomationElement()) {
|
|
54
|
-
|
|
54
|
+
startScan();
|
|
55
55
|
} else {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
waitForScannerReadiness()
|
|
57
|
+
.then(startScan)
|
|
58
|
+
.catch(async (err) => {
|
|
59
|
+
resolve("Scanner is not ready on the page after multiple retries. performscan");
|
|
60
|
+
});
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
})
|
|
63
63
|
|
|
64
64
|
const getAccessibilityResultsSummary = (win) =>
|
|
65
|
-
|
|
65
|
+
new Promise((resolve) => {
|
|
66
66
|
const isHttpOrHttps = /^(http|https):$/.test(window.location.protocol);
|
|
67
67
|
if (!isHttpOrHttps) {
|
|
68
|
-
|
|
68
|
+
resolve();
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
function findAccessibilityAutomationElement() {
|
|
72
|
-
|
|
72
|
+
return win.document.querySelector("#accessibility-automation-element");
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
function waitForScannerReadiness(retryCount = 30, retryInterval = 100) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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;
|
|
91
|
+
}
|
|
92
|
+
}, retryInterval);
|
|
93
|
+
});
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
function getSummary() {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
97
|
+
function onReceiveSummary(event) {
|
|
98
|
+
win.removeEventListener("A11Y_RESULTS_SUMMARY", onReceiveSummary);
|
|
99
|
+
resolve(event.detail);
|
|
100
|
+
}
|
|
102
101
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
win.addEventListener("A11Y_RESULTS_SUMMARY", onReceiveSummary);
|
|
103
|
+
const e = new CustomEvent("A11Y_GET_RESULTS_SUMMARY");
|
|
104
|
+
win.dispatchEvent(e);
|
|
106
105
|
}
|
|
107
106
|
|
|
108
107
|
if (findAccessibilityAutomationElement()) {
|
|
109
|
-
|
|
108
|
+
getSummary();
|
|
110
109
|
} else {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
110
|
+
waitForScannerReadiness()
|
|
111
|
+
.then(getSummary)
|
|
112
|
+
.catch((err) => {
|
|
113
|
+
resolve();
|
|
114
|
+
});
|
|
116
115
|
}
|
|
117
|
-
|
|
116
|
+
})
|
|
118
117
|
|
|
119
118
|
const getAccessibilityResults = (win) =>
|
|
120
|
-
|
|
119
|
+
new Promise((resolve) => {
|
|
121
120
|
const isHttpOrHttps = /^(http|https):$/.test(window.location.protocol);
|
|
122
121
|
if (!isHttpOrHttps) {
|
|
123
|
-
|
|
122
|
+
resolve();
|
|
124
123
|
}
|
|
125
124
|
|
|
126
125
|
function findAccessibilityAutomationElement() {
|
|
127
|
-
|
|
126
|
+
return win.document.querySelector("#accessibility-automation-element");
|
|
128
127
|
}
|
|
129
128
|
|
|
130
129
|
function waitForScannerReadiness(retryCount = 30, retryInterval = 100) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
130
|
+
return new Promise((resolve, reject) => {
|
|
131
|
+
let count = 0;
|
|
132
|
+
const intervalID = setInterval(() => {
|
|
133
|
+
if (count > retryCount) {
|
|
134
|
+
clearInterval(intervalID);
|
|
135
|
+
reject(
|
|
136
|
+
new Error(
|
|
137
|
+
"Accessibility Automation Scanner is not ready on the page."
|
|
138
|
+
)
|
|
139
|
+
);
|
|
140
|
+
} else if (findAccessibilityAutomationElement()) {
|
|
141
|
+
clearInterval(intervalID);
|
|
142
|
+
resolve("Scanner set");
|
|
143
|
+
} else {
|
|
144
|
+
count += 1;
|
|
145
|
+
}
|
|
146
|
+
}, retryInterval);
|
|
147
|
+
});
|
|
149
148
|
}
|
|
150
149
|
|
|
151
150
|
function getResults() {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
151
|
+
function onReceivedResult(event) {
|
|
152
|
+
win.removeEventListener("A11Y_RESULTS_RESPONSE", onReceivedResult);
|
|
153
|
+
resolve(event.detail);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
win.addEventListener("A11Y_RESULTS_RESPONSE", onReceivedResult);
|
|
157
|
+
const e = new CustomEvent("A11Y_GET_RESULTS");
|
|
158
|
+
win.dispatchEvent(e);
|
|
160
159
|
}
|
|
161
160
|
|
|
162
161
|
if (findAccessibilityAutomationElement()) {
|
|
163
|
-
|
|
162
|
+
getResults();
|
|
164
163
|
} else {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
164
|
+
waitForScannerReadiness()
|
|
165
|
+
.then(getResults)
|
|
166
|
+
.catch((err) => {
|
|
167
|
+
resolve();
|
|
168
|
+
});
|
|
170
169
|
}
|
|
171
|
-
|
|
170
|
+
});
|
|
172
171
|
|
|
173
172
|
const saveTestResults = (win, payloadToSend) =>
|
|
174
|
-
|
|
173
|
+
new Promise( (resolve, reject) => {
|
|
175
174
|
try {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
function findAccessibilityAutomationElement() {
|
|
182
|
-
return win.document.querySelector("#accessibility-automation-element");
|
|
183
|
-
}
|
|
175
|
+
const isHttpOrHttps = /^(http|https):$/.test(win.location.protocol);
|
|
176
|
+
if (!isHttpOrHttps) {
|
|
177
|
+
resolve("Unable to save accessibility results, Invalid URL.");
|
|
178
|
+
}
|
|
184
179
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
|
-
}
|
|
180
|
+
function findAccessibilityAutomationElement() {
|
|
181
|
+
return win.document.querySelector("#accessibility-automation-element");
|
|
182
|
+
}
|
|
205
183
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
184
|
+
function waitForScannerReadiness(retryCount = 30, retryInterval = 100) {
|
|
185
|
+
return new Promise((resolve, reject) => {
|
|
186
|
+
let count = 0;
|
|
187
|
+
const intervalID = setInterval(async () => {
|
|
188
|
+
if (count > retryCount) {
|
|
189
|
+
clearInterval(intervalID);
|
|
190
|
+
reject(
|
|
191
|
+
new Error(
|
|
192
|
+
"Accessibility Automation Scanner is not ready on the page."
|
|
193
|
+
)
|
|
194
|
+
);
|
|
195
|
+
} else if (findAccessibilityAutomationElement()) {
|
|
196
|
+
clearInterval(intervalID);
|
|
197
|
+
resolve("Scanner set");
|
|
198
|
+
} else {
|
|
199
|
+
count += 1;
|
|
200
|
+
}
|
|
201
|
+
}, retryInterval);
|
|
202
|
+
});
|
|
209
203
|
}
|
|
210
|
-
win.addEventListener("A11Y_RESULTS_SAVED", onResultsSaved);
|
|
211
|
-
const e = new CustomEvent("A11Y_SAVE_RESULTS", {
|
|
212
|
-
detail: payloadToSend,
|
|
213
|
-
});
|
|
214
|
-
win.dispatchEvent(e);
|
|
215
|
-
}
|
|
216
204
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
205
|
+
function saveResults() {
|
|
206
|
+
function onResultsSaved(event) {
|
|
207
|
+
resolve();
|
|
208
|
+
}
|
|
209
|
+
win.addEventListener("A11Y_RESULTS_SAVED", onResultsSaved);
|
|
210
|
+
const e = new CustomEvent("A11Y_SAVE_RESULTS", {
|
|
211
|
+
detail: payloadToSend,
|
|
212
|
+
});
|
|
213
|
+
win.dispatchEvent(e);
|
|
214
|
+
}
|
|
226
215
|
|
|
216
|
+
if (findAccessibilityAutomationElement()) {
|
|
217
|
+
saveResults();
|
|
218
|
+
} else {
|
|
219
|
+
waitForScannerReadiness()
|
|
220
|
+
.then(saveResults)
|
|
221
|
+
.catch(async (err) => {
|
|
222
|
+
resolve("Scanner is not ready on the page after multiple retries. after run");
|
|
223
|
+
});
|
|
224
|
+
}
|
|
227
225
|
} catch(er) {
|
|
228
|
-
|
|
226
|
+
resolve()
|
|
229
227
|
}
|
|
230
228
|
|
|
231
|
-
|
|
229
|
+
})
|
|
232
230
|
|
|
233
231
|
const shouldScanForAccessibility = (attributes) => {
|
|
234
|
-
|
|
232
|
+
if (Cypress.env("IS_ACCESSIBILITY_EXTENSION_LOADED") !== "true") return false;
|
|
235
233
|
|
|
236
|
-
|
|
237
|
-
|
|
234
|
+
const extensionPath = Cypress.env("ACCESSIBILITY_EXTENSION_PATH");
|
|
235
|
+
const isHeaded = Cypress.browser.isHeaded;
|
|
238
236
|
|
|
239
|
-
|
|
237
|
+
if (!isHeaded || (extensionPath === undefined)) return false;
|
|
240
238
|
|
|
241
|
-
|
|
239
|
+
let shouldScanTestForAccessibility = true;
|
|
242
240
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
241
|
+
if (Cypress.env("INCLUDE_TAGS_FOR_ACCESSIBILITY") || Cypress.env("EXCLUDE_TAGS_FOR_ACCESSIBILITY")) {
|
|
242
|
+
try {
|
|
243
|
+
let includeTagArray = [];
|
|
244
|
+
let excludeTagArray = [];
|
|
245
|
+
if (Cypress.env("INCLUDE_TAGS_FOR_ACCESSIBILITY")) {
|
|
246
|
+
includeTagArray = Cypress.env("INCLUDE_TAGS_FOR_ACCESSIBILITY").split(";")
|
|
247
|
+
}
|
|
248
|
+
if (Cypress.env("EXCLUDE_TAGS_FOR_ACCESSIBILITY")) {
|
|
249
|
+
excludeTagArray = Cypress.env("EXCLUDE_TAGS_FOR_ACCESSIBILITY").split(";")
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const fullTestName = attributes.title;
|
|
253
|
+
const excluded = excludeTagArray.some((exclude) => fullTestName.includes(exclude));
|
|
254
|
+
const included = includeTagArray.length === 0 || includeTags.some((include) => fullTestName.includes(include));
|
|
255
|
+
shouldScanTestForAccessibility = !excluded && included;
|
|
256
|
+
} catch (error) {
|
|
257
|
+
browserStackLog("Error while validating test case for accessibility before scanning. Error : ", error);
|
|
258
|
+
}
|
|
260
259
|
}
|
|
261
|
-
}
|
|
262
260
|
|
|
263
|
-
|
|
261
|
+
return shouldScanTestForAccessibility;
|
|
264
262
|
}
|
|
265
263
|
|
|
266
264
|
Cypress.on('command:start', async (command) => {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
265
|
+
if(!command || !command.attributes) return;
|
|
266
|
+
if(command.attributes.name == 'window' || command.attributes.name == 'then' || command.attributes.name == 'wrap') {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
271
269
|
|
|
272
|
-
|
|
270
|
+
if (!commandsToWrap.includes(command.attributes.name)) return;
|
|
273
271
|
|
|
274
|
-
|
|
272
|
+
const attributes = Cypress.mocha.getRunner().suite.ctx.currentTest || Cypress.mocha.getRunner().suite.ctx._runnable;
|
|
275
273
|
|
|
276
|
-
|
|
277
|
-
|
|
274
|
+
let shouldScanTestForAccessibility = shouldScanForAccessibility(attributes);
|
|
275
|
+
if (!shouldScanTestForAccessibility) return;
|
|
278
276
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
277
|
+
cy.window().then((win) => {
|
|
278
|
+
browserStackLog('Performing scan form command ' + command.attributes.name);
|
|
279
|
+
cy.wrap(performScan(win, {method: command.attributes.name}), {timeout: 30000});
|
|
280
|
+
})
|
|
283
281
|
})
|
|
284
282
|
|
|
285
283
|
afterEach(() => {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
284
|
+
const attributes = Cypress.mocha.getRunner().suite.ctx.currentTest;
|
|
285
|
+
cy.window().then(async (win) => {
|
|
286
|
+
let shouldScanTestForAccessibility = shouldScanForAccessibility(attributes);
|
|
287
|
+
if (!shouldScanTestForAccessibility) return cy.wrap({});
|
|
288
|
+
|
|
289
|
+
cy.wrap(performScan(win), {timeout: 30000}).then(() => {
|
|
290
|
+
try {
|
|
291
|
+
let os_data;
|
|
292
|
+
if (Cypress.env("OS")) {
|
|
293
|
+
os_data = Cypress.env("OS");
|
|
294
|
+
} else {
|
|
295
|
+
os_data = Cypress.platform === 'linux' ? 'mac' : "win"
|
|
296
|
+
}
|
|
297
|
+
let filePath = '';
|
|
298
|
+
if (attributes.invocationDetails !== undefined && attributes.invocationDetails.relativeFile !== undefined) {
|
|
299
|
+
filePath = attributes.invocationDetails.relativeFile;
|
|
300
|
+
}
|
|
301
|
+
const payloadToSend = {
|
|
302
|
+
"saveResults": shouldScanTestForAccessibility,
|
|
303
|
+
"testDetails": {
|
|
304
|
+
"name": attributes.title,
|
|
305
|
+
"testRunId": '5058', // variable not consumed, shouldn't matter what we send
|
|
306
|
+
"filePath": filePath,
|
|
307
|
+
"scopeList": [
|
|
308
|
+
filePath,
|
|
309
|
+
attributes.title
|
|
310
|
+
]
|
|
311
|
+
},
|
|
312
|
+
"platform": {
|
|
313
|
+
"os_name": os_data,
|
|
314
|
+
"os_version": Cypress.env("OS_VERSION"),
|
|
315
|
+
"browser_name": Cypress.browser.name,
|
|
316
|
+
"browser_version": Cypress.browser.version
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
browserStackLog(`Saving accessibility test results`);
|
|
320
|
+
cy.wrap(saveTestResults(win, payloadToSend), {timeout: 30000}).then(() => {
|
|
321
|
+
browserStackLog(`Saved accessibility test results`);
|
|
322
|
+
})
|
|
323
|
+
|
|
324
|
+
} catch (er) {
|
|
302
325
|
}
|
|
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
326
|
})
|
|
325
|
-
|
|
326
|
-
} catch (er) {
|
|
327
|
-
}
|
|
328
|
-
})
|
|
329
|
-
});
|
|
327
|
+
});
|
|
330
328
|
})
|
|
331
329
|
|
|
332
330
|
Cypress.Commands.add('performScan', () => {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
331
|
+
try {
|
|
332
|
+
const attributes = Cypress.mocha.getRunner().suite.ctx.currentTest || Cypress.mocha.getRunner().suite.ctx._runnable;
|
|
333
|
+
const shouldScanTestForAccessibility = shouldScanForAccessibility(attributes);
|
|
334
|
+
if (!shouldScanTestForAccessibility) {
|
|
335
|
+
browserStackLog(`Not a Accessibility Automation session, cannot perform scan.`);
|
|
336
|
+
return cy.wrap({});
|
|
337
|
+
}
|
|
338
|
+
cy.window().then(async (win) => {
|
|
339
|
+
browserStackLog(`Performing accessibility scan`);
|
|
340
|
+
await performScan(win);
|
|
341
|
+
});
|
|
342
|
+
} catch {}
|
|
345
343
|
})
|
|
346
344
|
|
|
347
345
|
Cypress.Commands.add('getAccessibilityResultsSummary', () => {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
346
|
+
try {
|
|
347
|
+
const attributes = Cypress.mocha.getRunner().suite.ctx.currentTest || Cypress.mocha.getRunner().suite.ctx._runnable;
|
|
348
|
+
const shouldScanTestForAccessibility = shouldScanForAccessibility(attributes);
|
|
349
|
+
if (!shouldScanTestForAccessibility) {
|
|
350
|
+
browserStackLog(`Not a Accessibility Automation session, cannot retrieve Accessibility results summary.`);
|
|
351
|
+
return cy.wrap({});
|
|
352
|
+
}
|
|
353
|
+
cy.window().then(async (win) => {
|
|
354
|
+
await performScan(win);
|
|
355
|
+
browserStackLog('Getting accessibility results summary');
|
|
356
|
+
return await getAccessibilityResultsSummary(win);
|
|
357
|
+
});
|
|
358
|
+
} catch {}
|
|
359
|
+
|
|
362
360
|
});
|
|
363
361
|
|
|
364
362
|
Cypress.Commands.add('getAccessibilityResults', () => {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
363
|
+
try {
|
|
364
|
+
const attributes = Cypress.mocha.getRunner().suite.ctx.currentTest || Cypress.mocha.getRunner().suite.ctx._runnable;
|
|
365
|
+
const shouldScanTestForAccessibility = shouldScanForAccessibility(attributes);
|
|
366
|
+
if (!shouldScanTestForAccessibility) {
|
|
367
|
+
browserStackLog(`Not a Accessibility Automation session, cannot retrieve Accessibility results.`);
|
|
368
|
+
return cy.wrap({});
|
|
369
|
+
}
|
|
372
370
|
|
|
373
|
-
/* browserstack_accessibility_automation_script */
|
|
371
|
+
/* browserstack_accessibility_automation_script */
|
|
374
372
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
373
|
+
cy.window().then(async (win) => {
|
|
374
|
+
await performScan(win);
|
|
375
|
+
browserStackLog('Getting accessibility results');
|
|
376
|
+
return await getAccessibilityResults(win);
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
} catch {}
|
|
380
380
|
|
|
381
|
-
} catch {}
|
|
382
|
-
|
|
383
381
|
});
|