Pls say, How I can past only letters in my tests. Like this
const uuid = () => Cypress._.random('^[A-Za-z]+$')
const id = uuid()
const firstname = `${id}`
cy.get('.firstname').type(firstname)
Pls say, How I can past only letters in my tests. Like this
const uuid = () => Cypress._.random('^[A-Za-z]+$')
const id = uuid()
const firstname = `${id}`
cy.get('.firstname').type(firstname)
⚠ If you want to generate UUIDs be aware that not all characters in a UUID are random: Read here on Wikipedia.
I personally use this small package to generate UUIDs
If you need more generated data for your tests I'd recommend chance.js. You can read more about generating UUIDs here chance.js/uuid
Generating UUIDs on your own was already answered in this mega thread here: How to create GUID / UUID?
If you don't care if some of the strings are duplicates of each other (e.g. for first names), you could just
const generate = () => {
document.body.innerHTML = `${document.body.innerHTML} ${Math.random().toString(36).substring(2)}`;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<button type="button" id="btn" onclick="generate()">
Generate string
</button>
</body>
</html>