https://cypress.io logo
Anyone stuck with Azure AD authentication login fo...
# best-practices
n
Anyone stuck with Azure AD authentication login for end to end test, here is solution. you need to have following config in your Cypress.config.js file. Cypress.config.js const { defineConfig } = require("cypress"); module.exports = defineConfig({ chromeWebSecurity: false, e2e: { experimentalSessionAndOrigin: true, experimentalModifyObstructiveThirdPartyCode : true, }, }); ////////// and this is your test file - login.js (this is example test) . replace 'https://shop.company.com/' with your site url. describe('Azure AD login solution', () => { it('Login with my Azure AD credentials and then redirected back to my main website', () => { cy.origin(
https://login.microsoftonline.com/
, () => { cy.visit('https://shop.company.com/'); cy.get('[name="loginfmt"]').type(
${Cypress.env("username")}{enter}
); cy.wait(2000); cy.get('[name="passwd"]').type(
${Cypress.env("password")}{enter}
); cy.wait(2000); cy.get('[type="submit"]').type('{enter}'); }); }) })