automated tests – In case cypress finds the path and is stuck with not.exist error

By Groupda Whatsapp Group Link

Updated On:

Follow Us

I want to compare path Alert with ExpectedResult, but now the programer not check script in this part, so I use not.exist to skip case that Path Alert is not found, but in case that path Alert is found, Cypress program still reads . not.exist, and I want it to run through it without getting this error.

Join Now:  Indian WhatsApp Group Names

Timed out retrying after 4000ms: Expected

  • not to exist in the DOM, but it was continuously found.
    if (cy.get('.help-block > ul > li').should('not.exist')) {
                cy.get('.help-block > ul > li').should('not.exist').then((Path_Alert) => {
                  console.log(Path_Alert)
                  if (Path_Alert == null) {
                    cy.log(data.rows[i].ExpectedResult)
                    ErrorSuggestion = cy.log('Not Alert or Alert Not Match').as('ErrorSuggestion')
                  }
                })
                cy.get('#swal2-title').should('be.visible').invoke('text').then((text) => {
                  if (text == 'พบข้อผิดพลาด!' || text == 'การเพิ่มสำเร็จ!') {
                    cy.log(text).as('Alert_Popup')
                    if (text == 'พบข้อผิดพลาด!') {
                      result="Fail"
                      cy.log(result).as('Result')
                      cy.get('.swal2-confirm').click()
                    } else if (text == 'การเพิ่มสำเร็จ!') {
                      cy.get('.swal2-confirm').click()
                    }
    
                  }
                })
              } else {
                if (cy.get('.help-block > ul > li').should('be.visible')) {
                  cy.get('.help-block > ul > li').should('be.visible').then((Path_Alert) => {
                    console.log(Path_Alert)
                    if (expect(Path_Alert).equal(data.rows[i].ExpectedResult)) {
                      result="Pass"
                      cy.log(result).as('Result')
                    }
                  })
                }
    
                cy.get('#swal2-title').should('be.visible').invoke('text').then((text) => {
                  if (text == 'พบข้อผิดพลาด!' || text == 'การเพิ่มสำเร็จ!') {
                    cy.log(text).as('Alert_Popup')
                    if (text == 'พบข้อผิดพลาด!') {
                      result="Fail"
                      cy.log(result).as('Result')
                      cy.get('.swal2-confirm').click()
                    } else if (text == 'การเพิ่มสำเร็จ!') {
                      cy.get('.swal2-confirm').click()
                    }
    
                  }
                })
              } 
    

    enter image description here

    Join Now:  Tea Jul Age, Bio, Spouse, Photo, Height, Net Worth
  • Source link

    Leave a Comment

    + Add Whatsapp
    + Telegram