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

350
Vistas
how to javascript data validation by cypress?

I have a list, which lists getting from javascript. How to verify the javascript data by cypress. I am trying to automate a project. Attached are the features screenshot. how-to javascript data validation by cypress?

enter image description here

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

0

The test should generally follow the way you'd manually test the page, for example on first loading "North America" is the active page, so test that link is active.

Then test the content is correct, both titles and images, after that moving on to other tabs.

An example,

cy.visit('https://my-vacation.com/home')

cy.contains('a.js-tab-links', 'North America')
  .should('have.class', 'active')                  // this link is active after loading

// Titles on the page
cy.contains('Galveston Vacation Rentals')
cy.contains('Sedona Vacation Rentals')
//  ... same for remaining titles

// Images on the page
cy.get('img[src="galveston-island-historic-pleasure-pier.jpg"]')
// ... same for other images


// Other tabs
cy.contains('a.js-tab-links', 'South America')
  .click()                                      // activate this tab
  .should('have.class', 'active')

// Titles on the page
cy.contains('Peru Vacation Rentals')
cy.contains('Argentina Vacation Rentals')
//  ... same for remaining titles

// Images on the page
cy.get('img[src="machu-pichu.jpg"]')
// ... same for other images

You can break it up so that each section has it's own test

before(() => {
  cy.visit('my-vacation.html')  // visit once before all the tests
})

it('North America', () => {
  cy.contains('a.js-tab-links', 'North America')
    .should('have.class', 'active')                  // this link is active after loading

  // Titles on the page
  cy.contains('Galveston Vacation Rentals')
  cy.contains('Sedona Vacation Rentals')
  //  ... same for remaining titles

  // Images on the page
  cy.get('img[src="galveston-island-historic-pleasure-pier.jpg"]')
  // ... same for other images
})

it('South America', () => {
  cy.contains('a.js-tab-links', 'South America')
    .click()                                      // activate this tab
    .should('have.class', 'active')

  // Titles on the page
  cy.contains('Peru Vacation Rentals')
  cy.contains('Argentina Vacation Rentals')
  //  ... same for remaining titles

  // Images on the page
  cy.get('img[src="machu-pichu.jpg"]')
  // ... same for other images
})

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can directly assert any of the continents directly using eq -

cy.get('.location-selector ul li a').eq(0).should('have.text', 'North America')
cy.get('.location-selector ul li a').eq(1).should('have.text', 'South America')

And if you want to assert all the continents, you can also use a each and validate -

var continents = [
  'North America',
  'South America',
  'Europe',
  'Asia',
  'Australia/NZ',
  'Middle East/Africa',
]

cy.get('.location-selector ul li a').each(($ele, index) => {
  expect($ele.text().trim()).to.equal(continents[index])
})
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