Search code examples
javaperformanceseleniumwebdriver

How to efficiently send large String to java selenium textarea element


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);
      }