Generate a random email for Signup in Cypress Automation:
Method 1:
It will generate any random value between 0 and 1e6 For example, it will be look like (e8dq43@yopmail.com)
var uuid = () => Cypress._.random(0, 1e6)
var id = uuid()
var testname = ${id}@yopmail.com
cy.get('#email').type(testname);
Method 2:
It will generate any random value by using any alphabetic and numeric Values. For example, it will be look like (ghulam.nabi+123
@gmail.com)
cy.get('#email').should('be.visible').type(userID_Alpha())
function userID_Alpha() {
var email = "ghulam.nabi+"
var text = "";
var possible = "qwertyuioplkjhgfdazxcvbnm1234567890";
for (var i = 0; i < 4; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
var value = email + text.concat('@gmail.com')
return value;
}
Leave a comment