cy.getIframeBody().find('#some-button')我在使用#some-button 元素尚不可用时遇到问题,因为 iframe 仍在加载,但 body 元素不为空,因此触发了 .find() 。
这是获取 iframe 主体的自定义命令
Cypress.Commands.add('getIframeBody', ()=> {
return cy.get('iframe.cy-external-link-container')
.its('0.contentDocument.body')
.should('not.empty')
.then(cy.wrap)
});
Run Code Online (Sandbox Code Playgroud)
我怎样才能在不使用的情况下做到这一点cy.wait()?