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
  • 374,785
  • 51
  • 663
  • 734
MasterNone
  • 528
  • 1
  • 5
  • 18
  • 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
  • 131,952
  • 11
  • 151
  • 228