[SOLVED] 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

Answer Checked By – Mary Flores (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *