Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

387
Visualizações
cy.click() failed because it requires a DOM element?
  it('TC01 - ', () => {
    const dataToTest = productCatalogData.case1
    createGLCode(dataToTest)
    toastMessageIsEqualsTo('GL Code Created!')
  });

  it('TC02 - ', () => {
    const dataToTest = productCatalogData.case2
    editGLCode(dataToTest)
    //toastMessageIsEqualsTo('GL Code Updated!')
  });

  it('TC03 - ', () => {
    const dataToTest = productCatalogData.case3
    deleteGLCode(dataToTest)
    toastMessageIsEqualsTo('GL Code Deleted!')

I have logout function in afterEach hook.

But at the time of 3rd test case, it is showing me an error of "cy.click() failed because it requires a DOM element." and "The subject received was: undefined".

However, when I run the same test case again, it works perfectly fine.

| export const clickLogout = () => {
> 5 |   cy.get('[id=logoutBtn]').click({ force: true });
    |                            ^
  6 | };

Giving error here.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It looks like cy.get('[id=logoutBtn]') is missing from the DOM because of the logout in the afterEach().

I presume somewhere in those custom methods you are logging in. (BTW you should do it explicitly in the test to make it easier to understand your tests).

If so, add a visibility check to the logout button

cy.get('[id=logoutBtn]')
  .should('be.visible')
  .click({ force: true })

If that's not it, you will have to add all the custom code to the question, as the problem lies somewhere in there.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda