Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

351
Views
¿Cómo hacer la validación de datos de javascript por ciprés?

Tengo una lista, que enumera obtener de javascript. Cómo verificar los datos de javascript por cypress. Estoy tratando de automatizar un proyecto. Se adjunta la captura de pantalla de las características. ¿cómo validar datos javascript por ciprés?

ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

La prueba generalmente debe seguir la forma en que probaría manualmente la página, por ejemplo, al cargar por primera vez, "Norteamérica" es la página activa, así que pruebe que el enlace está activo.

Luego prueba que el contenido es correcto, tanto los títulos como las imágenes, y luego pasa a otras pestañas.

Un ejemplo,

 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

Puede dividirlo para que cada sección tenga su propia prueba

 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 Report

0

Puede afirmar directamente cualquiera de los continentes directamente usando 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')

Y si desea afirmar todos los continentes, también puede usar each y validar:

 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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!