Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

174
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda