0

I am using an application where every time, I need to create a new users. I want code that can generate the same for me through regular expression. Example- Alen001, Alen002, Alen003 and so on.

driver.findElement(By.id("userId")).sendKeys("Alen001");
Norayr Sargsyan
  • 1,737
  • 1
  • 12
  • 26
Gaurav
  • 101
  • 3
  • 12

1 Answers1

0

To create a new random userid e.g. Alen001, Alen002, Alen003 etc, and pass it through sendKeys() you can use the following line of code:

driver.findElement(By.id("userId")).sendKeys("Alen00"+ Integer.toString(((new Random().nextInt(10))+1)));
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352