我正在使用此代码 我已经使用了每个属性,但没有找到
cy.get('.gjs-frame')
.then(($iframe) => {
const $body = $iframe.contents().find('body')
cy.wrap($body)
//cy.get('#v-app')
//cy.get('.layout')
//cy.get('.gjs-hovered')
//.get('.v-application--wrap [data-gjs-type="wrapper"]')
// .get('[data-gjs-type="wrapper"]')
//.get('#v-app .v-application--wrap')
//.get('.v-application--wrap')
// .get('#v-mount').should('be.exist')
})
答案 0 :(得分:1)
引用:Working with iframes in Cypress
const getIframeDocument = () => {
return cy.get('iframe').its('0.contentDocument').should('exist')
};
const getIframeBody = () => {
// get the document
return getIframeDocument()
.its('body').should('not.be.undefined')
.then(cy.wrap);
}
getIframeBody().find(<selector>).should('contain', <content>);