簡體   English   中英

無法訪問 Static 下拉菜單 Iframe

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM