有一个具有 Auth0 身份验证的应用程序。我正在研究 Cypress 测试套件。今天,在本地进行多次测试后,Auth0 开始在登录页面上显示验证码。这是很难自动化的事情,我不想这样做。
有什么方法可以在 Auth0 中禁用 Cypress 测试的验证码吗?有什么解决方法吗?我找到了几篇如何使用 api 调用生成身份验证 token 的文章,但我个人不支持这种做法。这是端到端测试,我们应该像使用黑匣子一样使用应用程序。
请指教。谢谢。
最佳答案
如果你这样重新来过,
你可以试试,
/**
* This method use to submit the the reCaptcha.
*/
Cypress.Commands.add ("authenticateWithReCaptcha",()=>{
cy.window().then(currentWindow => {
const params = new URLSearchParams(currentWindow.location.search);
if (params.has("reCaptcha") &&
currentWindow.document
.querySelector("iframe[src*='recaptcha']") &&
getComputedStyle(currentWindow.document
.querySelector("iframe[src*='recaptcha']")).visibility === "visible") {
cy.window().invoke("submitForm");
}
});
});
https://stackoverflow.com/questions/71390327/
相关文章:
typescript - 如何使用带有更新的 FirestoreDataConverter?
javascript - 为什么 Jest 在 node-fetch 上失败,在导入时给出语法错误
sql - 如何在 Snowflake 中嵌套使用一个流的存储过程?
swift - AVPlayer 在 iOS 15.4 中寻求 completionHandler
reactjs - 使用 useEffect 监听子组件可以吗?
telegram - 热门从 Telegram Bot 消息中获取回调数据