无法使用柏树访问 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]')
      
    });
    
  });

我可以在您的网页中看到阴影 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()