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

262
Vistas
How to test multiple floating messages with the same content in cypress?

I am fairly new to cypress and practicing its functionalities on Facebook app. I am having an issue on testing these following scenarios:

1.When clicked on First Name, this floating dialog should be visible. 2.Validating the text in the dialog box to be 'What's your name?'. 3.When clicked on Last Name, again a floating box with the same content "What's your name?" should be visible.

Now I am able to test the first two scenario with this.

cy.get('[name="firstname"]').click();//i)-> Click on the firstname
        cy.get('[name="lastname"]').click();//ii)-> Click on the last name    
        cy.get('[name="firstname"]').click(); //iii)-> This will triggers the error message popup for firstname 
        cy.contains('What\'s your name?').should('be.visible').and('contain','What\'s your name?');// Checking the message popup should be displayed and its message is 'What's your name'
        cy.get('[name="lastname"]').click();//v)-> This will trigger the error message popup for lastname
    
        cy.contains('What\'s your name?').should('be.visible').and('contain','What\'s your name?');//vi)-> Checking for that message but not working

But in the third scenario, it is showing the error. I tried to access the element using id but it was showing not found. Error Message Facebook Page

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

0

I think cy.contains('What\'s your name?') is catching the message from firstName field which was activated from the initial two commmands but hidden when you navigated to the lastName field (but still remains in the page).

Specify which one you want

cy.get('div:contains(What\'s your name?)').eq(1).should('be.visible')  // .and(contain) not needed

In case that quote in the text distorts the selection you may need to go with cy.get('div:contains(your name?)').eq(1).

Don't use cy.contains('What\'s your name?') it will only ever return the first one it finds.

The Facebook page is not very tester friendly, usually you can request the page elements have some test id's added so you can go directly to then.

Another way to tackle the anonymous popup stuff is just to grab the last thing added to the page, like

cy.get('body')
  .children()
  .last()
  .should('contain', 'What\'s your name?')
  .should('be.visible')
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