Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

379
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda