vendredi 19 février 2021

How can I validate empty fields with cypress:

I already have a method that validate when they have some information on it, but when there is nothing it's crash

Cypress.Commands.add('selectedFilterPlan', (filterId, idComponentList) => {
  cy.get(filterId).should('be.visible');
  cy.get(filterId).should('have.value', '');
  cy.get(filterId)
  .then((selects) => {
    let select = selects[0];
    cy.wrap(select).click();
      if(cy.get(idComponentList).should("be.visible")){
        cy.get(idComponentList)
        .get("nz-option-item")
        .then(function(item) {
        cy.wrap(item[0]).click();
        cy.wait(500);
        cy.get("[data-cy=result-filter-list]").should("be.visible");
        });
      }
 });
});

_

    it('select dropdown plan filters', () => {
      cy.selectedFilterPlan('[data-cy=id-filter-1]', "#cdk-overlay-1");
      cy.selectedFilterPlan('[data-cy=id-filter-2]', "#cdk-overlay-2");
      cy.selectedFilterPlan('[data-cy=id-filter-3]', "#cdk-overlay-3");
      cy.selectedFilterPlan('[data-cy=id-filter-4]', "#cdk-overlay-4");
      cy.selectedFilterPlan('[data-cy=id-filter-5]', "#cdk-overlay-5");
    });

I want to create a method that validate and pass to the next field when its empty

enter image description here

Aucun commentaire:

Enregistrer un commentaire