After login to Microsoft Azure AD, unable to redirect back to base URL #29850
Unanswered
viditasatam
asked this question in
Questions and Help
Replies: 1 comment
-
I am seeing the same issue with Cypress 13.8.1. The page is stuck on the redirect url, if I copy / paste the url in cypress browser into another browser it will correctly perform the redirect. It seems like cypress is preventing it due to origin command would be my guess.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am working on a cypress+ cucumber project. There is a scenario where I login to a URL. I am prompted a Microsoft login popup. I am handling the popup, authenticating the otp, and expecting to go back to the URL and page to load but the URL does not load and the page is blank.
My cypress.config.js looks like:
const { defineConfig } = require('cypress');
const createBundler = require("@bahmutov/cypress-esbuild-preprocessor");
const preprocessor = require("@badeball/cypress-cucumber-preprocessor");
const createEsbuildPlugin = require("@badeball/cypress-cucumber-preprocessor/esbuild");
const fs = require("fs");
const path = require("path");
module.exports = defineConfig({
e2e: {
chromeWebSecurity: false,
setupNodeEvents(on, config) {
on("file:preprocessor",
createBundler({
plugins: [createEsbuildPlugin.default(config)],
}));
preprocessor.addCucumberPreprocessorPlugin(on, config);
// require('cypress-mochawesome-reporter/plugin')(on);
on("task", {
log(message) {
console.log(message)
return null
},
});
on("task", {
verifyFileDownloaded(partialFileName) {
const downloadDir = config.downloadsFolder || "cypress/downloads";
const files = fs.readdirSync(downloadDir);
return files.some((file) => file.includes(partialFileName));
},
clearDownloads() {
const downloadDir = config.downloadsFolder || "cypress/downloads";
fs.readdirSync(downloadDir).forEach((file) => {
const filePath = path.join(downloadDir, file);
fs.unlinkSync(filePath);
});
return null;
}
});
return config;
},
baseUrl: "",
experimentalMemoryManagement: false,
experimentalModifyObstructiveThirdPartyCode: true,
experimentalOriginDependencies: false,
modifyObstructiveCode: false,
contentSecurityPolicy: false,
trashAssetsBeforeRuns: true,
watchForFileChanges: false,
defaultCommandTimeout: 18000,
numTestsKeptInMemory: 1,
defaultCommandTimeout: 10000,
pageLoadTimeout: 60000,
specPattern: 'cypress/e2e/features//.feature',
reporter: 'mocha-multi-reporters',
reporterOptions: {
configFile: 'reporter-config.json',
},
viewportWidth: 1400,
viewportHeight: 1080,
downloadsFolder: "cypress/downloads",
},
});
My login code looks like:
this.elements.continueBtn().click();
// Verify window.open was called
cy.get('@Windowopen').should('be.called');
cy.get('@Windowopen').then((spy: any) => {
const fullPopupUrl = spy.getCall(0).args[0]; // Extract URL from the first call
const url = new URL(fullPopupUrl);
// Extract necessary parameters
const baseUrl = url.origin; // Extract base URL
const path = url.pathname + url.search; // Extract path including search params
// Use cy.origin() to handle commands on the new origin
cy.origin(baseUrl, { args: { path } }, ({ path }) => {
cy.visit(path, { timeout: 20000 }); // Increased timeout
// Wait for the email input to be visible and interact
cy.get('input[type=email]', { timeout: 10000 })
.should('be.visible')
.then((input) => {
cy.wrap(input).type('');
cy.get('input[type=submit]').click();
// Wait for the password input to be visible and interact
cy.get('input[type=password]', { timeout: 10000 })
.should('be.visible')
.then((input) => {
cy.wrap(input).type('');
cy.get('input[type=submit]').click();
});
});
});
// Check if redirected to the target URL
cy.url().should('contain', '***');
am expecting to redirect to my base URL after the authentication is completed successfully.
Tool/library versions:
node: v20.12.2
cypress: 12.10.0
Beta Was this translation helpful? Give feedback.
All reactions