Last active
December 2, 2023 01:41
-
-
Save belajargitbinar/f4d43aebdcc1490fb06d27e631fb6a95 to your computer and use it in GitHub Desktop.
random email generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random | |
import java.util.Collections | |
def getRandomName() { | |
def names = ['john', 'alice', 'bob', 'emma', 'david'] | |
Collections.shuffle(names) | |
return names.first() | |
} | |
def getRandomString(int length) { | |
def characters = ('abcdefghijklmnopqrstuvwxyz0123456789' as char[]).toList() | |
Collections.shuffle(characters) | |
return (1..length).collect { characters[it % characters.size()] }.join() | |
} | |
def generateRandomEmail() { | |
def randomName = getRandomName() | |
def randomChars = getRandomString(7) | |
def domain = 'example.com' | |
return "${randomName}${randomChars}@${domain}" | |
} | |
def randomEmail = generateRandomEmail() | |
// Put it on global variable or just simply put on send keys params | |
// example to put it on global variable, you need to create this variable first on global variable with empty value | |
GlobalVariable.random_email = randomEmail |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment