sendkeys() sometimes truncate the entered text

I’m using sendkeys method to input some text, like “DiscardTestUlitiscayle”, but some time it will input “DiscardTestUlit” instead, miss last -XXXXXX. then I clear the text field and try to input one more time, but still same error. Anyone know the reason? and how to resolve the issue? Thanks in advance!

lixiuhua_2012 Default Asked on December 18, 2015 in Selenium WebDriver.
Add Comment
1 Answer(s)

There could be two reason that I suspect here
– Your webpage has pending Javascript/Ajax calls which come in later and reset the focus from the element.
– You are doing a multithread test run where at the same time you tests are trying to type something on two different browsers. That dosent seem to be the case here.

How can you fix it?
Try these one by one
– Before doing SendKeys do
– Use javascript to set the value, here is a sample code

WebElement element = driver.FindElement(<Yur locator>);
((JavascriptExecutor) driver).executeScript(“arguments[0].value = ‘something'”, element);

Try the two methods and let us know.


Virender Singh Professor Answered on December 19, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.