WinAppDriver: sendkeys fails with error An unknown error occurred in the remote end while processing the command

My testcode will launch microsoftword and tries to type inside. Here is the code I am using


    	String application="C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\WINWORD.EXE";
    	String appWorkingDir="c:\\tmp";
    	//To suppress the splash screen and want to use blank word doc. so we use flags /q and /w flags respectively
    	String appArguments = "/q /w";
...
....
....
WebElement element =  ((WindowsDriver) webDriver).findElement("name", "Page 1 content");
		if ( element != null ) {
					element.sendKeys(keysToSend);
               }

When I debug I notice that webelement is not NULL…But sendKeys is failing on it. I get exception “An unknown error occurred in the remote end while processing the command.” I am not sure how to proceed…

WinAppDriver log

POST /wd/hub/session/7D092E3B-44FD-4C0F-957C-4F99363BEF69/element/42.1115954.2.2/value HTTP/1.1
Accept-Encoding: gzip,deflate
Connection: Keep-Alive
Content-Length: 55
Content-Type: application/json; charset=utf-8
Host: 10.173.75.51:4723
User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_112)

{"id":"42.1115954.2.2","value":["This is sample text"]}
HTTP/1.1 500 Internal Error
Content-Length: 133
Content-Type: application/json

{"status":13,"value":{"error":"unknown error","message":"An unknown error occurred in the remote end while processing the command."}}

It will be helpful for us if you print what exactly went wrong. Please help me to proceed further.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 28 (14 by maintainers)

Most upvoted comments

What makes me crazy is it sometimes work fine. But Once fails, It continuously fails. if I wait few minutes or restart computer, it works( or sometimes not!).

I can also verify this issue. It only occurs for us when running tests from a tfs build agent

I can create a test that executes perfectly on the machine. If I execute the same test on the same machine via a tfs build, it fails at sendkeys with an “unknown error” it appears to be able to click find other elements without issue. SendKeys() and clear() both appear to fail

@timotiusmargo can you pls help me here…can you pls post a code that opens winword on a remote machine and types helloworld? why it works for notepad and fails for MSWord?

@Jteve-Sobs You can find Windows Settings -> Time & Language -> Language -> Add a preferred language I don’t know setting to English is important or not. In my cases, when set to my local keyboard(It can toggle English and Korean using ALT key) I got the error. But English(United States) is working

Thanks for the update @shankarkc!. I’m glad it worked out well. Note that you may still need to refer to “Page 1 Content” when you are trying to retrieve the text value. E.g.

// Send the text input
RemoteWebElement element = session.FindElementByName("Document1");
if (element != null)
{
    element.Click();
    element.SendKeys("Test");
}

// Get the text value
RemoteWebElement element1 = session.FindElementByName("Page 1 content");
if (element1 != null)
{
    var text = element1.Text;
}

@timotiusmargo thanks for the pointers. Its working now. I realized now that there are some UI elements that cannot take keyboard inputs and if we send keybord inputs it will fail. As per your suggestion when i used Document1 it works and I am able to type text inside word document.

@hassanuz / @timotiusmargo any updates on this? My team is kind of blocked bcz of this issue. We cannot run the tests in CI environment as we need to run WAD on a remote machine. Your fast response highly appreciated.