简体   繁体   English

赛普拉斯模态不关闭

[英]Cypress modal doesn't close

I've read 5-6 relevant Stackoverflow threads, none appear to pertain to this (famous last words).我已经阅读了 5-6 个相关的 Stackoverflow 线程,似乎没有一个与此有关(著名的遗言)。

Cypress 12.3.0 (was happening on v9 so I upgraded, but the issue persists). Cypress 12.3.0(发生在 v9 上,所以我升级了,但问题仍然存在)。

Problem only occurs in automation.问题只发生在自动化中。

Test conducted in headed mode (Cypress > Edge).测试在 headed 模式下进行(Cypress > Edge)。

  1. Click delete icon单击删除图标
  2. Modal appears模态出现
  3. Click delete button in modal单击模态中的删除按钮

Expected result:预期结果:

Action performed, modal closes.执行的操作,模式关闭。

Actual result:实际结果:

Action performed, modal doesn't close.执行的操作,模态不关闭。

Troubleshooting:故障排除:

I added a command to close the modal using the modal's X button = Cypress can't find it.我添加了一个命令来使用模态的 X 按钮关闭模态 = 赛普拉斯找不到它。

If I don't add the above command, the succeeding test steps cannot click on elements because the modal that allegedly doesn't exist is covering them!如果我不添加上面的命令,后续的测试步骤将无法点击元素,因为据称不存在的模态正在覆盖它们!

In Cypress > Edge, I can interact with and inspect the modal's elements.在 Cypress > Edge 中,我可以与模态元素交互并检查模态元素。

This is crazy.这太疯狂了。

Code:代码:

cy.contains('button', 'Delete Queue')
.click();

No iframes involved.不涉及 iframe。

I'm enquiring internally to establish what JavaScript event or logic is closing the modal so I can trigger that.我正在内部查询以确定关闭模态的 JavaScript 事件或逻辑是什么,以便我可以触发它。 Or close the modal if it can be found with JavaScript...或者如果可以通过 JavaScript 找到模态,则关闭模态...

Just wondered if you guys have any ideas?只是想知道你们有什么想法吗?

Thanks谢谢

For whatever reason the app wouldn't close the modal after deleting the queue so I closed it myself using the correct CSS selector .无论出于何种原因,应用程序在删除队列后都不会关闭模式,所以我使用正确的 CSS 选择器自己关闭了它。

Maybe this can resolve your problem:也许这可以解决您的问题:

cy.contains('button', 'Delete Queue')
.click();
cy.get('[data-test-id="modal-close-button"]')
.click();

Let me know if it works.让我知道它是否有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM