Skip to content

Error when try examples in python and ts #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
doubianimehdi opened this issue Apr 12, 2025 · 10 comments · Fixed by #7
Closed

Error when try examples in python and ts #1

doubianimehdi opened this issue Apr 12, 2025 · 10 comments · Fixed by #7

Comments

@doubianimehdi
Copy link

when i launch the client_example.py with python client_example.py from the examples directory i have :
--- 1. Opening Application ---

--- 2. Defining Locators ---

--- 3. Getting Initial Text ---
ERROR: API Error (500): Automation error: Unsupported operation: selectors selector not supported
Warning: Could not get initial display text: API Error (500): Automation error: Unsupported operation: selectors selector not supported

--- 4. Performing Clicks --- (1 + 2 =)
ERROR: API Error (500): Automation error: Unsupported operation: selectors selector not supported

API Error occurred: API Error (500): Automation error: Unsupported operation: selectors selector not supported

Please help :)

@frank06n
Copy link

frank06n commented Apr 14, 2025

I'm facing the same error

Image

@louis030195
Copy link
Contributor

louis030195 commented Apr 14, 2025

which version of the server are you running?

make sure to update server regularly or build from source

@louis030195
Copy link
Contributor

yo i fixed the issue ,can you either redownload the server running the getting started again

https://docs.screenpi.pe/terminator/getting-started

eg

.\setup_windows.ps1
./server_release/server.exe --debug

and tell me if the example works now?

@kantandesu
Copy link

kantandesu commented Apr 14, 2025

yo i fixed the issue ,can you either redownload the server running the getting started again

https://docs.screenpi.pe/terminator/getting-started

eg

.\setup_windows.ps1
./server_release/server.exe --debug
and tell me if the example works now?

both python and typescript scripts are giving the same error :

ERROR: API Error (500): Automation error: Operation timed out: Timed out after 3s waiting for element Chain([Role { role: "window", name: Some("Calculator") }, Role { role: "Id", name: Some("CalculatorResults") }]) to be visible
Warning: Could not get initial display text: API Error (500): Automation error: Operation timed out: Timed out after 3s waiting for element Chain([Role { role: "window", name: Some("Calculator") }, Role { role: "Id", name: Some("CalculatorResults") }]) to be visible

--- 4. Performing Clicks --- (1 + 2 =)
ERROR: API Error (500): Automation error: Element not found: Name: 'One', Err: find element time out

API Error occurred: API Error (500): Automation error: Element not found: Name: 'One', Err: find element time out 

@doubianimehdi
Copy link
Author

C:\terminator\examples\client_example.py:9: SyntaxWarning: invalid escape sequence '\p'
SDK_PATH = os.path.abspath(os.path.join(os.path.dirname(file), 'C:\terminator\python-sdk', 'python-sdk'))
INFO: DesktopUseClient initialized for server at http://127.0.0.1:3000

--- 1. Opening Application ---

--- 2. Defining Locators ---

--- 3. Getting Initial Text ---
ERROR: API Error (500): Automation error: Operation timed out: Timed out after 3s waiting for element Chain([Role { role: "window", name: Some("Calculator") }, Role { role: "Id", name: Some("CalculatorResults") }]) to be visible
Warning: Could not get initial display text: API Error (500): Automation error: Operation timed out: Timed out after 3s waiting for element Chain([Role { role: "window", name: Some("Calculator") }, Role { role: "Id", name: Some("CalculatorResults") }]) to be visible

--- 4. Performing Clicks --- (1 + 2 =)
ERROR: API Error (500): Automation error: Element not found: Name: 'One', Err: find element time out

API Error occurred: API Error (500): Automation error: Element not found: Name: 'One', Err: find element time out

@louis030195
Copy link
Contributor

louis030195 commented Apr 14, 2025

do you have calculator app on your computer? are you on windows?

C:\terminator\examples\client_example.py:9: SyntaxWarning: invalid escape sequence '\p' SDK_PATH = os.path.abspath(os.path.join(os.path.dirname(file), 'C:\terminator\python-sdk', 'python-sdk')) INFO: DesktopUseClient initialized for server at http://127.0.0.1:3000

--- 1. Opening Application ---

--- 2. Defining Locators ---

--- 3. Getting Initial Text --- ERROR: API Error (500): Automation error: Operation timed out: Timed out after 3s waiting for element Chain([Role { role: "window", name: Some("Calculator") }, Role { role: "Id", name: Some("CalculatorResults") }]) to be visible Warning: Could not get initial display text: API Error (500): Automation error: Operation timed out: Timed out after 3s waiting for element Chain([Role { role: "window", name: Some("Calculator") }, Role { role: "Id", name: Some("CalculatorResults") }]) to be visible

--- 4. Performing Clicks --- (1 + 2 =) ERROR: API Error (500): Automation error: Element not found: Name: 'One', Err: find element time out

API Error occurred: API Error (500): Automation error: Element not found: Name: 'One', Err: find element time out

@louis030195
Copy link
Contributor

yo i fixed the issue ,can you either redownload the server running the getting started again
https://docs.screenpi.pe/terminator/getting-started
eg
.\setup_windows.ps1
./server_release/server.exe --debug
and tell me if the example works now?

both python and typescript scripts are giving the same error :

ERROR: API Error (500): Automation error: Operation timed out: Timed out after 3s waiting for element Chain([Role { role: "window", name: Some("Calculator") }, Role { role: "Id", name: Some("CalculatorResults") }]) to be visible
Warning: Could not get initial display text: API Error (500): Automation error: Operation timed out: Timed out after 3s waiting for element Chain([Role { role: "window", name: Some("Calculator") }, Role { role: "Id", name: Some("CalculatorResults") }]) to be visible

--- 4. Performing Clicks --- (1 + 2 =)
ERROR: API Error (500): Automation error: Element not found: Name: 'One', Err: find element time out

API Error occurred: API Error (500): Automation error: Element not found: Name: 'One', Err: find element time out 

does it open calculator app? do you have calculator app? are you on windows right? this is for windows only

@doubianimehdi
Copy link
Author

@louis030195 yes it opens the calculator , i'm on windows but it doesn't register the 1 + 2 = part ...

@frank06n
Copy link

frank06n commented Apr 15, 2025

@louis030195 I've just checked with the updated server.exe. The clicking on buttons 1 + 2 = 3 occurs.. but now I'm getting Timeout error in the getting initial text & verifying final text part.

Here's the complete log -

--- 1. Opening Application ---
[TerminatorClient] Sending POST to /open_application with payload: {"app_name":"Calc"}
[TerminatorClient] Response Status: 200
[TerminatorClient] Response Data: {"message":"Application 'Calc' opened"}

--- 2. Defining Locators ---

--- 3. Getting Initial Text ---
[TerminatorClient] Sending POST to /expect_visible with payload: {"selector_chain":["window:Calculator","Id:CalculatorResults"],"timeout_ms":3000}
[TerminatorClient] Response Status: 500
[TerminatorClient] Response Data: {"message":"Automation error: Operation timed out: Timed out after 3s waiting for element Chain([Role { role: \"window\", name: Some(\"Calculator\") }, Role { role: \"Id\", name: Some(\"CalculatorResults\") }]) to be visible"}
[TerminatorClient] Error: Automation error: Operation timed out: Timed out after 3s waiting for element Chain([Role { role: "window", name: Some("Calculator") }, Role { role: "Id", name: Some("CalculatorResults") }]) to be visible, Detail: {"message":"Automation error: Operation timed out: Timed out after 3s waiting for element Chain([Role { role: \"window\", name: Some(\"Calculator\") }, Role { role: \"Id\", name: Some(\"CalculatorResults\") }]) to be visible"}
Could not get initial display text: Automation error: Operation timed out: Timed out after 3s waiting for element Chain([Role { role: "window", name: Some("Calculator") }, Role { role: "Id", name: Some("CalculatorResults") }]) to be visible

--- 4. Performing Clicks --- (1 + 2 =)
[TerminatorClient] Sending POST to /click with payload: {"selector_chain":["window:Calculator","Name:One"]}
[TerminatorClient] Response Status: 200
[TerminatorClient] Response Data: {"method":"Single Click","coordinates":null,"details":"Clicked by Mouse"}
[TerminatorClient] Sending POST to /click with payload: {"selector_chain":["window:Calculator","Name:Plus"]}
[TerminatorClient] Response Status: 200
[TerminatorClient] Response Data: {"method":"Single Click","coordinates":null,"details":"Clicked by Mouse"}
[TerminatorClient] Sending POST to /click with payload: {"selector_chain":["window:Calculator","Name:Two"]}
[TerminatorClient] Response Status: 200
[TerminatorClient] Response Data: {"method":"Single Click","coordinates":null,"details":"Clicked by Mouse"}
[TerminatorClient] Sending POST to /click with payload: {"selector_chain":["window:Calculator","Name:Equals"]}
[TerminatorClient] Response Status: 200
[TerminatorClient] Response Data: {"method":"Single Click","coordinates":null,"details":"Clicked by Mouse"}

--- 5. Verifying Final Text --- (Expecting 3)
[TerminatorClient] Sending POST to /expect_text_equals with payload: {"selector_chain":["window:Calculator","Id:CalculatorResults"],"expected_text":"3","max_depth":1,"timeout_ms":5000}
[TerminatorClient] Response Status: 500
[TerminatorClient] Response Data: {"message":"Automation error: Operation timed out: Timed out after 5s waiting for element Chain([Role { role: \"window\", name: Some(\"Calculator\") }, Role { role: \"Id\", name: Some(\"CalculatorResults\") }]) text to equal '3'"}
[TerminatorClient] Error: Automation error: Operation timed out: Timed out after 5s waiting for element Chain([Role { role: "window", name: Some("Calculator") }, Role { role: "Id", name: Some("CalculatorResults") }]) text to equal '3', Detail: {"message":"Automation error: Operation timed out: Timed out after 5s waiting for element Chain([Role { role: \"window\", name: Some(\"Calculator\") }, Role { role: \"Id\", name: Some(\"CalculatorResults\") }]) text to equal '3'"}      
Verification failed or could not get final text: Automation error: Operation timed out: Timed out after 5s waiting for element Chain([Role { role: "window", name: Some("Calculator") }, Role { role: "Id", name: Some("CalculatorResults") }]) text to equal '3'
[TerminatorClient] Sending POST to /get_text with payload: {"selector_chain":["window:Calculator","Id:CalculatorResults"]}
[TerminatorClient] Response Status: 200
[TerminatorClient] Response Data: {"text":""}
Raw text on failure:

--- Example: Get Attributes of '=' button ---
[TerminatorClient] Sending POST to /get_attributes with payload: {"selector_chain":["window:Calculator","Name:Equals"]}
[TerminatorClient] Response Status: 200
[TerminatorClient] Response Data: {"role":"Button","label":null,"value":"","description":"","properties":{"AutomationId":"STRING(equalButton)","HelpText":"STRING()","ValueValue":"STRING()","FullDescription":"STRING()","Name":"STRING(Equals)","LabeledBy":"NULL","ControlType":"I4(50000)"},"id":"equalButton"}
Equals button attributes: {
  "role": "Button",
  "label": null,
  "value": "",
  "description": "",
  "properties": {
    "AutomationId": "STRING(equalButton)",
    "HelpText": "STRING()",
    "ValueValue": "STRING()",
    "FullDescription": "STRING()",
    "Name": "STRING(Equals)",
    "LabeledBy": "NULL",
    "ControlType": "I4(50000)"
  },
  "id": "equalButton"
}

--- Example: Check Visibility of '=' button ---
[TerminatorClient] Sending POST to /is_visible with payload: {"selector_chain":["window:Calculator","Name:Equals"]}
[TerminatorClient] Response Status: 200
[TerminatorClient] Response Data: {"result":false}
Is Equals button visible? false

--- Example Finished --- (Press Ctrl+C if server doesn't exit)

This is the server side log

2025-04-15T01:01:37.146758Z  INFO server: listening on 127.0.0.1:3000
2025-04-15T01:01:50.247670Z  INFO server: Attempting to open application app_name=Calc
2025-04-15T01:01:50.791851Z DEBUG terminator::platforms::windows: searching application from name: Calc
2025-04-15T01:01:51.205480Z  INFO server: Application opened successfully
2025-04-15T01:01:53.218175Z  INFO server: Attempting to expect element visible chain=["window:Calculator", "Id:CalculatorResults"] timeout=Some(3000)
2025-04-15T01:01:56.324458Z  INFO server: Expect visible failed: Operation timed out: Timed out after 3s waiting for element Chain([Role { role: "window", name: Some("Calculator") }, Role { role: "Id", name: Some("CalculatorResults") }]) to be visible
2025-04-15T01:01:56.324571Z ERROR server: Automation error: Timeout("Timed out after 3s waiting for element Chain([Role { role: \"window\", name: Some(\"Calculator\") }, Role { role: \"Id\", name: Some(\"CalculatorResults\") }]) to be visible")
2025-04-15T01:01:56.328108Z  INFO server: Attempting to click element chain=["window:Calculator", "Name:One"]
2025-04-15T01:01:56.369507Z DEBUG terminator::platforms::windows: searching element by name: One
2025-04-15T01:01:56.389076Z DEBUG terminator::platforms::windows: attempting to click element: UIElement { name: "One", control_type: Button, classname: "Button" }
2025-04-15T01:01:57.096066Z  INFO server: Element clicked successfully
2025-04-15T01:01:57.610397Z  INFO server: Attempting to click element chain=["window:Calculator", "Name:Plus"]
2025-04-15T01:01:57.658787Z DEBUG terminator::platforms::windows: searching element by name: Plus
2025-04-15T01:01:57.672916Z DEBUG terminator::platforms::windows: attempting to click element: UIElement { name: "Plus", control_type: Button, classname: "Button" }
2025-04-15T01:01:58.349060Z  INFO server: Element clicked successfully
2025-04-15T01:01:58.857478Z  INFO server: Attempting to click element chain=["window:Calculator", "Name:Two"]
2025-04-15T01:01:58.907071Z DEBUG terminator::platforms::windows: searching element by name: Two
2025-04-15T01:01:58.923688Z DEBUG terminator::platforms::windows: attempting to click element: UIElement { name: "Two", control_type: Button, classname: "Button" }
2025-04-15T01:01:59.574671Z  INFO server: Element clicked successfully
2025-04-15T01:02:00.083454Z  INFO server: Attempting to click element chain=["window:Calculator", "Name:Equals"]
2025-04-15T01:02:00.128135Z DEBUG terminator::platforms::windows: searching element by name: Equals
2025-04-15T01:02:00.143004Z DEBUG terminator::platforms::windows: attempting to click element: UIElement { name: "Equals", control_type: Button, classname: "Button" }
2025-04-15T01:02:00.780818Z  INFO server: Element clicked successfully
2025-04-15T01:02:01.790030Z  INFO server: Attempting to expect text equals chain=["window:Calculator", "Id:CalculatorResults"] text=3 depth=Some(1) timeout=Some(5000)
2025-04-15T01:02:06.885017Z  INFO server: Expect text equals failed: Operation timed out: Timed out after 5s waiting for element Chain([Role { role: "window", name: Some("Calculator") }, Role { role: "Id", name: Some("CalculatorResults") }]) text to equal '3'
2025-04-15T01:02:06.885102Z ERROR server: Automation error: Timeout("Timed out after 5s waiting for element Chain([Role { role: \"window\", name: Some(\"Calculator\") }, Role { role: \"Id\", name: Some(\"CalculatorResults\") }]) text to equal '3'")
2025-04-15T01:02:06.887462Z  INFO server: Attempting to get text chain=["window:Calculator", "Id:CalculatorResults"] max_depth=5
2025-04-15T01:02:07.202318Z  INFO server: Text retrieved successfully
2025-04-15T01:02:07.204487Z  INFO server: Attempting to get attributes chain=["window:Calculator", "Name:Equals"]
2025-04-15T01:02:07.251636Z DEBUG terminator::platforms::windows: searching element by name: Equals
2025-04-15T01:02:10.316716Z ERROR server: Automation error: ElementNotFound("Name: 'Equals', Err: find element time out")

@louis030195
Copy link
Contributor

will look into this, i suspect UIs changes over different windows version

keep in mind everything is very experimental and bugs are to be expected (but report these and we'll fix ASAP), i recommend using AI and providing terminator sdk as tools a bit like here

readDesktopUseDocs: tool({

and AI will figure out how to retry and find right element to click/read

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants