我有一个弹出窗口,除非用户将其关闭,否则不会关闭,因此最终会阻止我的测试中的内容,从而导致失败。我尝试了Cypress iframe插件,cy.wrap()
解决方案和自定义命令,但它们都无法用于单击关闭图标。我可以找到iframe没问题,但是在iframe中找不到任何元素。
cy.get('iframe[class="intercom-zsm3q8 e1o2sc8n0"]')
.iframe('body span[class="intercom-anchor intercom-1tdusvr e12dv51w1"]').click()
错误:
cy.click() failed because it requires a DOM element.
The subject received was:
> {}
答案 0 :(得分:0)
您可以运行此代码段并查看其是否有效。最近,我从事与iframe元素交互的项目。
cy.get("iframe").then( $iframe =>
const $doc = $iframe.contents();
cy.wait(3000).wrap( $doc.find("write the class name here") ).click({ force: true })
});