How to efficiently send large String to java selenium textarea element

Issue

I need to send Large text in the type of String to textArea element. I use

driver.findElement(By.xpath(textarea_xpath)).sendKeys(fileText);

But Its too slow. Any ideas to make this fast?

Solution

You can try it with JS executor:

  public void enterTextJS(By locator, String text) {
    JavascriptExecutor jsExecutor = (JavascriptExecutor) driver;
    WebElement element = driver.findElement(locator);
    jsExecutor.executeScript("arguments[0].value='" + text + "';", element);
  }

Answered By – Villa_7

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published