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

170
Vistas
How to create or update the user based on the availability of the founded user?

I am trying to test a cypress test based on the found user. It works separately to update a user if there is a user, or create a new user. But I am trying to create or edit users based on conditions, but it's not working. here is a try.

        UserHelpers.filterUser("mama");

        //Update User
        cy.get(".rt-tbody").children().contains(webAdminUser.userName);
        cy.get(`[id^='Edit_${webAdminUser.userName}']`).first().click();
        UserHelpers.updateUser(webAdminUser);

        // create a user, if there is no user
        cy.get(".rt-noData").contains("No data found");
        UserHelpers.createUser(webAdminUser);

        // cy.get(".rt-tbody").then(($element) => {
        //  if ($element.has('[id^="Edit_Cypress"]')) {
        //      cy.log("logggecd");
        //      UserHelpers.updateUser(webAdminUser);
        //  } else {
        //      UserHelpers.createUser(webAdminUser);
        //  }
        // });

        // if (cy.get(".rt-tbody").children().contains(webAdminUser.userName)) {
        //  UserHelpers.updateUser(webAdminUser);
        // } else {
        //  UserHelpers.createUser(webAdminUser);
        // }

How can I update or create a user base of the if-else condition?

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

0

You should avoid conditionals in tests as it goes against best practice.

But if you really want to do that I advise you to read this Cypress documentation on testing with conditionals: https://docs.cypress.io/guides/core-concepts/conditional-testing#What-you-ll-learn

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