【发布时间】:2021-12-07 09:44:08
【问题描述】:
我有一些代码试图捕获 iframe 中的元素,但我总是被抛出一个错误
it('Send Medication',function(){
cy.get('.aut-iframe')
.should(iframe => expect(iframe.contents().find('body')).to.exist)
.then(iframe => cy.wrap(iframe.contents().find('body')))
.within({}, $iframe => {
cy.get('.pending-medication-check-box').click({force:true})
这是我得到的错误:
最后,这是 iframe 信息:
【问题讨论】:
-
<iframe id="Your App: '...'" class="aut-iframe" src="..."></iframe>是赛普拉斯测试运行器的一部分,因此您不能使用赛普拉斯测试命令来访问它 - 为什么要这样做?如果您有另一个 iframe 实际上是应用程序的一部分,则需要在测试中更改选择器。 -
你是对的,Fody,在进行了更多挖掘之后,我注意到我需要的实际 iframe 已嵌入到我最初尝试使用的 iframe 中
标签: javascript iframe cypress cypress-component-test-runner