Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Selenium ChromeDriver SendKeys is really slow

I have a problem with Selenium and Chrome. I need to send via SendKeys a really big string (>20'000 characters). It starts very fast, but then it keeps slowing down until it stops sending keys to my body contenteditable=true which i'm referring to by xpath. The browser then is not responding, and I need to kill it via the task manager (I am on Windows 10).

UPDATE: I also tried to send less characters splitting the String and putting some sleeps. The problem is not caused by the amount of character chromedriver has to write, but by the amount of characters in a textbox.


1 Answers

You may try to use an alternative way to enter characters, by means of JavaScript.

WebElement element = driver.findElement(By.xpath(yourXpath));
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("arguments[0].innerText=arguments[1];", element, yourLongText);
like image 87
Monsignor Avatar answered Sep 02 '25 21:09

Monsignor