Forum Discussion

mfoster711's avatar
mfoster711
Regular Contributor
21 days ago

Using Test Engine Rest API

I am trying to use the Test Engine REST API | TestComplete Documentation.

I am using windows Notepad to perform a few tests. I am able to perform SetText or Click methods on the field but Keys does not work.

Here is the call and error I get when performing Keys:

curl -X 'GET' \
  'http://localhost:2377/1/sys/a6ac403a-99db-4f51-bbda-f8f46faa447b/method/Keys?arg1=%22random%20test%20message%22' \
  -H 'accept: application/json'

{
  "success": false,
  "errorMessage": "The operation was interrupted by the user."
}

Here is successful example of SetText method on same field.

curl -X 'GET' \
  'http://localhost:2377/1/sys/a6ac403a-99db-4f51-bbda-f8f46faa447b/method/SetText?arg1=%22random%20test%20message%22' \
  -H 'accept: application/json'

{
  "success": true,
  "result": {
    "value": null
  }
}

Why doesn't Keys work?

3 Replies

  • Hassan_Ballan's avatar
    Hassan_Ballan
    Icon for Champion Level 3 rankChampion Level 3

    Short answer: Keys() simulates real keyboard input, while SetText() directly sets the control’s text. Because of this, Keys() requires an active, focused window and an interactive desktop session—conditions that are often not met when using the Test Engine REST API.

    🤖 AI-assisted response
    👍 Found it helpful? Click Like
    ✅ Issue resolved? Click Mark as Solution

     

    • mfoster711's avatar
      mfoster711
      Regular Contributor

      I have an active, focused window and interactive desktop. I am able to use the Click method that would also require an active window.

  • mfoster711's avatar
    mfoster711
    Regular Contributor

    I figured it out. I had failed to perform the Initialize api call at the beginning which resulted in the keys method failing. The only odd part is that the other methods were working without having to do initialize first.