我正在设置新的cypress测试来测试Dynamics 365应用程序中的一些功能。但是,我留下了一个浏览器窗口,其中包含网址https://login.microsoftonline.com/__/和文本Whoops,没有运行测试。
describe('Initial Cypress Tests',()=> {
it('navigate to D365', () => {
cy.visit('https://wipropoc.crm8.dynamics.com')
} )
})
建议您直接进行POST调用以获取SSO身份验证令牌并使用获取的令牌触发cy.visit('https://wipropoc.crm8.dynamics.com')
。
以下是官方文档中要遵循的步骤,
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)
})
你可以在这里阅读更多相关信息 - https://docs.cypress.io/guides/guides/web-security.html#Form-Submission-Redirects
实时示例 - https://xebia.com/blog/how-to-use-azure-ad-single-sign-on-with-cypress/