I am setting up new cypress tests to test some functionalities in Dynamics 365 application. But, I'm left with a browser window with the url https://login.microsoftonline.com/__/ and the text Whoops, there is no test to run.
describe('Initial Cypress Tests', () => {
it('navigate to D365', () => {
cy.visit('https://wipropoc.crm8.dynamics.com')
})
})
Would suggest you to directly do a POST call for getting SSO authentication token and fire cy.visit('https://wipropoc.crm8.dynamics.com')
with the obtained token.
Here are the steps to follow from official documentation,
cy.request()
.cy.request('POST', 'https://sso.corp.com/auth', { username: 'foo', password: 'bar' })
.then((response) => {
// pull out the location redirect
const loc = response.headers['Location']
// parse out the token from the url (assuming its in there)
const token = parseOutMyToken(loc)
// do something with the token that your web application expects
// likely the same behavior as what your SSO does under the hood
// assuming it handles query string tokens like this
cy.visit('http://localhost:8080?token=' + token)
// if you don't need to work with the token you can sometimes
// just visit the location header directly
cy.visit(loc)
})
You can read more about this here - https://docs.cypress.io/guides/guides/web-security.html#Form-Submission-Redirects
Real time example - https://xebia.com/blog/how-to-use-azure-ad-single-sign-on-with-cypress/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With