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

175
Views
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 answers
Answer question

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 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!