Skip to content

add window support #382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions accessibility/scanner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const sendScanData = (win, payload) => {
});
};

async function processAccessibilityReport(url,newWindow) {
async function processAccessibilityReport(url,windowNew) {
try {
let wcagCriteriaValue = Cypress.env("WCAG_CRITERIA") || "wcag21a";
let bestPracticeValue = Cypress.env("BEST_PRACTICE") === "true";
Expand All @@ -101,7 +101,7 @@ async function processAccessibilityReport(url,newWindow) {

console.log('log', "SET SCAN: Payload to send: for url: ", payloadToSend,url);
try {
let setResult = await setScanConfig(newWindow, payloadToSend);
let setResult = await setScanConfig(windowNew, payloadToSend);
console.log('SET SCAN: response:', setResult);
} catch (err) {
console.error("SET SCAN: Error while setting scan", err);
Expand All @@ -111,7 +111,7 @@ async function processAccessibilityReport(url,newWindow) {
let scanData;
try {
const payload = {message: 'GET_LATEST_SCAN_DATA'};
scanData = await getScanData(newWindow, payload);
scanData = await getScanData(windowNew, payload);
LambdatestLog("GET SCAN:LambdaTest Accessibility: Scanning URL");
} catch (err) {
console.error("GET SCAN:Error while setting scan", err);
Expand All @@ -134,7 +134,7 @@ async function processAccessibilityReport(url,newWindow) {
apiUrl: reportAPI
};
try{
let response = await sendScanData(newWindow,payloadToSend);
let response = await sendScanData(windowNew,payloadToSend);
console.log("Accessibility Report Response:", response);
}catch(e){
console.error("Error in Accessibility Report Response:",e);
Expand Down Expand Up @@ -228,10 +228,17 @@ if (overRideCommands) {
return originalFn(url, options);
}

const currentWindow = window; //
return originalFn(url, options).then(async () => {
await processAccessibilityReport(url,currentWindow);
})
return cy.window().then((currentWindowNew) => {
Cypress.log({
name: command, // Display the passed command name
displayName: `Accessibility: ${command}`, // Change how it looks in the Cypress log
message: url,
});

return originalFn(url, options).then(() => {
return processAccessibilityReport(url, currentWindowNew);
});
});

});
});
Expand Down