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

180
Vistas
Unable to find element after adding className in html file

If I am manually adding id , test-id or classname in html file . Here I have added 'Classname' just as an example to show you.

enter image description here Cypress is not able to find the elemententer image description here

using cy.get(".todo-list") to locate the button as I have mentioned classname (shown in screenshot). enter image description here

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Try using the class instead of className attribute on the button. For example, class="todo-list".

Some things like JSX in React use className due to the fact that class is a reserved keyword in JavaScript, but since this is vanilla HTML it isn't necessary. Also, for the future, could you paste the code snippets instead of just screenshots?

about 4 years ago · Juan Pablo Isaza Denunciar

0

@Bryce is correct (assuming it's not a React app), but in general any attribute can be queried using an extended syntax

cy.get('[className="todo-list"]')

Looking at the UIKit docs,

By default, all classes and attributes in UIkit start with the uk- prefix. This avoids name collisions when introducing UIkit to existing projects or when combining it with other frameworks.

so maybe add the class prefix uk- (although this may just be to avoid conflict in the style sheets and have no bearing on the test).

<button class="uk-todo-list" >
cy.get('.todo-list')

Generally speaking, using a class is less solid than using a data-cy attribute, since classes also control styling and may be changed in the future.

Cypress recommends this

<button data-cy="todo-list" >
cy.get('[data-cy="todo-list"]')
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