We recently faced with an Selenium’s sendKeys() method issue which is related to the page which was made in Angular 1.5.8 (Most likely the same issue can be discovered in different versions). In most of the cases, the input field filled by sendKeys() method will contain just part of the desired text. Most often you will find just the first half of you desired text written into the input field. From our experience this bug appears only in the following circumstances:

  1. Page must be made with Angular
  2. The input field must be tagged with angular attributes, like ngModel, ngControl, etc.

As a simple and temporary solution we created a method based on another solution (View the issue on Github). Here we check whether the desired text is entered or not. If the entered text is not equal to the desired one, we clear out the input field and write into it character by character. The code snippet what we use can be found below:

//type the text char by char if usual sendkeys fails
	public void secureSendkeys(WebElement element, String text){
		String insertedValue = element.getAttribute("value");
		if (!insertedValue.equals(text)) {
			// Failed, must send characters one by one
			logger.debug("sendkeys failed, expected: " + text + " found in inbox: " + insertedValue + ". Now we try to type text char by char");
			for(int i = 0; i < text.length(); i++){
				element.sendKeys("" + text.charAt(i));

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>