簡體   English   中英

無法使用 cypress 訪問 html 元素

[英]unable to access html element using cypress

我正在嘗試使用 cypress 測試登錄功能,但由於某種原因,我無法訪問輸入文本框。 它顯示 Timed out retrying after 4000ms: Expected to find element: runner container, but never found it。

describe("User authentication", () => {
    beforeEach(() => {
      cy.visit("https://lmflf.com");
     
    });
    it("it takes to the correct page", () => {
   
      cy.get('[data-field=password]')
      
    });
    
  });

我可以在您的網頁中看到一個 shadow DOM,在這種情況下,您必須使用.shadow() ( Cypress Docs )。 您的代碼如下所示:

cy.get('view-login').shadow().find('input[data-field="username"]').type('username', {force: true})
cy.get('view-login').shadow().find('input[data-field="password"]').type('password', {force: true})
cy.get('view-login').shadow().find('input[value="personal"]').click()
cy.get('view-login').shadow().find('.ViewLogin__button').click()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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