[英]Can't Access Static Drop-down Inside an Iframe
我想单击 iframe 和 select 一些选项中的下拉菜单,但我在柏树中不断收到此错误
cypress-iframe 命令一次只能应用于一个 iframe。 而是找到了 2
请在下面查看我的代码`
it('Publish and Lock Results', function(){
setClasses.clickTools()
setClasses.clickConfiguration()
setClasses.publishAndLockResult()
cy.frameLoaded();
cy.wait(5000)
cy.iframe().find("body > div:nth-child(6) > div:nth-child(1) > div:nth-child(1) > form:nth-child(2) > table:nth-child(5) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(2) > div:nth-child(5) > p:nth-child(2)").click()
})
```**Please see screenshot of the element**
[![enter image description here](https://i.stack.imgur.com/WpUfn.png)](https://i.stack.imgur.com/WpUfn.png)
应该有一个您可以使用的标识符 iframe(iframe 的任何其他标识符、唯一 ID、class 或属性,例如data-test
)
let iframe = cy.get(iframeIdentifier).its('0.contentDocument.body').should('not.be.empty').then(cy.wrap)
iframe.find("body > div:nth-child(6) > div:nth-child(1) > div:nth-child(1) > form:nth-child(2) > table:nth-child(5) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(2) > div:nth-child(5) > p:nth-child(2)").click()
根据 output 的建议,您在该页面上有两个 iframe,它试图向其发送命令,您必须选择一个
答案改编自来源: cypress.io 关于使用 iframe 的博客文章
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.