1

I want to add about 1000 or 10000 repeating letters/words to a textarea with:

driver.findElement(By.name("message")).sendKeys("asdasdsadasdasdasdasdasdasdasd");

I haven't found a proper example how to achieve this.

Eran
  • 387,369
  • 54
  • 702
  • 768
MasterNone
  • 558
  • 1
  • 5
  • 20
  • Use RandomStringUtils package to generate a string. Then send it via sendKeys(randomString); – Turcia Dec 04 '15 at 22:56

1 Answers1

1

Just build a string to pass to sendKeys:

StringBuilder sb = new StringBuilder(1000);
while (sb.length() < 1000) {
  sb.append("sequencetorepeat");
}
webElement.sendKeys(sb.toString());

There are more efficient ways to repeat strings, but this is a simple approach for reasonably short strings.

Community
  • 1
  • 1
Andy Turner
  • 137,514
  • 11
  • 162
  • 243