无法获得cypress中iframe下的元素 [英] Unable to get element which is in under a Iframe in cypress

查看:448
本文介绍了无法获得cypress中iframe下的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用此代码
i使用了每个属性,但没有找到

Am using this code i have used each and every attribute but did not find

我的html代码

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')

})


推荐答案

参考:在赛普拉斯中使用iframe

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>);

这篇关于无法获得cypress中iframe下的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆