The solution to this issue is to create a function that will create random text + adding a string that will complete the email.
My solution is:
function makeid(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
console.log(makeid(5));
My cypress command will be the following:
Cypress.Commands.add("form", ()=> {
// fill-out form
function makeid(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
console.log(makeid(5));
cy.get('#full_name')
.type('MOCKDATA TESTING')
cy.get('#company')
.type('Testing')
cy.get('#phone_number')
.type('2022569878')
cy.get('#email')
.type(makeid(6) + "@aharo.com")
cy.get('#password')
.type('Abcd1234')
// click submit
cy.get(".app-submit-btn-text").click()
})
The best way to call this command is cy.form
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…