lundi 25 janvier 2021

Function that allow me to create random email for cypress test

I'm looking into a function that allows me to create random emails where I would like to add it to the Email input inside of my test. For this reason, I created this function. However, I'm not sure how to add it to my cypress test.

Function:

 it('Product |  build or Remodel', () => {
    
    
    function string(){
    }
    
    chars = 'abcdefghijklmnopqrstuvwxyz1234567890';
    string = '';
    email = '@aharotest.com';
    
    for(var ii=0; ii<15; ii++){
        string += chars[Math.floor(Math.random() * chars.length)];
    }

    console.log(string + email)
    
    cy.oneTime()
    cy.buildRemodel()
    cy.get('#full_name')
    .type('MOCKA DATA TEST')
    cy.get('#company')
    .type('Bluehost')
    cy.get('#phone_number')
    .type('2022569879')
    cy.get('#email')
    cy.get('#password')
    .type('Abcd1234')
    cy.logOut()
  })

My element is #email

What could be the best way to approach this situation.

Aucun commentaire:

Enregistrer un commentaire