RuntimeError: The object does not exist
Hello, I need help with a persistent issue in TestComplete using Python scripting. I created a helper method with chatGPT that waits for UI objects and executes actions safely. However, I am constantly getting RuntimeError: The object does not exist, even when the UI object is on screen. The important detail is that this error happens BEFORE my helper executes, meaning TestComplete tries to resolve the alias too early, even if I pass it inside a lambda. The errors I am getting include: RuntimeError: The object does not exist I tried several approaches: using lambda wrappers, string-based alias evaluation with eval, safe exists checks, try/except wrapping, WaitProperty with catch, RefreshMappingInfo, and returning stub objects. Still, TestComplete tries to resolve the alias too early and throws a RuntimeError before my code handles it. I want to know if TestComplete officially supports passing object references using lambda in Python without resolving them immediately, or if there is a recommended approach for safe deferred resolution of Alias-based UI objects. Here is the simplified version of my helper (the stable version): # ============================================================ # LIB_IfObject.py # Helper for safe object waits and actions in TestComplete # ============================================================ class IfObjectHelper: """ Waits, validates, and executes actions on TestComplete UI objects, handling object recreation, timing issues, and temporary unavailability. """ @staticmethod def Run(obj, accion=None, timeout=40000, descripcion="object", intentos_accion=1, opcional=False): """ Waits until the object exists and optionally executes an action. Parameters: obj: object reference or lambda returning the object dynamically. accion: function/lambda to execute over the object. timeout: maximum wait time in milliseconds. descripcion: text description for logs. intentos_accion: number of retries if the action fails. opcional: if True, missing objects do not fail the test (for optional popups). """ try: timeout = timeout or 40000 start = aqDateTime.Now() found = False resolved_obj = None # === Attempt to resolve the object === for _ in range(3): try: resolved_obj = obj() if callable(obj) else obj if not hasattr(resolved_obj, "WaitProperty"): Delay(100) continue resolved_obj.RefreshMappingInfo() # === Handle RuntimeError for dynamic UI objects === try: # Retry if the object is not instantiated or was recreated if not getattr(resolved_obj, "Exists", False): Delay(200) resolved_obj = obj() if callable(obj) else obj resolved_obj.RefreshMappingInfo() except RuntimeError: # If the handle does not exist yet, wait and retry Delay(300) try: resolved_obj = obj() if callable(obj) else obj resolved_obj.RefreshMappingInfo() except: Delay(100) # === Extended verification of visibility and enabled state === if (resolved_obj.WaitProperty("Exists", True, timeout) and resolved_obj.WaitProperty("VisibleOnScreen", True, int(timeout / 2))): # If the object exists but is disabled, treat as informational if not resolved_obj.Enabled: Log.Message(f"ℹ {descripcion} found but disabled (action skipped).") return True found = True break except Exception: Delay(100) # === Handle non-existing object === if not found: if opcional or "popup" in descripcion.lower(): Log.Message(f"ℹ {descripcion} not found (optional, skipping).") return True else: Log.Warning(f"❌ {descripcion} not found after {timeout/1000:.1f}s.") return False # === Execute action (if provided) === if accion: success = False for attempt in range(1, intentos_accion + 1): try: # Validate that the object still exists if not getattr(resolved_obj, "Exists", False): Log.Warning(f"⚠️ {descripcion}: object disappeared before action, retrying...") try: resolved_obj = obj() if callable(obj) else obj resolved_obj.RefreshMappingInfo() except: Delay(200) continue # Handle actions passed as list/tuple if isinstance(accion, (list, tuple)): for sub in accion: try: sub() except Exception as sub_e: Log.Warning(f"⚠ Sub-action error for {descripcion}: " f"{type(sub_e).__name__} - {str(sub_e)}") Delay(100) else: # Standard single action accion() success = True Log.Checkpoint(f"✅ {descripcion} found and action executed successfully.") break except Exception as e: # Diagnostic block to identify failing object/action try: origin = getattr(resolved_obj, "FullName", str(resolved_obj)) Log.Warning(f"⚠ Attempt {attempt}/{intentos_accion} failed in {descripcion}: " f"{type(e).__name__} - {str(e)} | Object: {origin}") except: Log.Warning(f"⚠ Attempt {attempt}/{intentos_accion} failed in {descripcion}: {str(e)}") Delay(500) try: resolved_obj.RefreshMappingInfo() except: Delay(100) if not success: Log.Error(f"❌ Action failed in {descripcion} after {intentos_accion} attempts.") return False else: Log.Message(f"✔ {descripcion} found (no action executed).") # === Total execution time === duration = aqDateTime.TimeInterval(start, aqDateTime.Now()) Log.Message(f"⏱ Total time for {descripcion}: {duration:.2f} sec.") return True except Exception as e: import traceback detail = traceback.format_exc() Log.Error(f"General error in {descripcion}: {type(e).__name__} - {str(e)}", detail) return False My questions: 1. Is there an official recommended pattern for safely resolving dynamic alias-based objects in Python for desktop testing? 2. Does TestComplete support passing object references via lambda without resolving them prematurely? 3. Is there any documented workaround for avoiding early alias evaluation inside Python? Any help will be appreciated. Thank you.40Views0likes2CommentsHow to Create/Import Description File for JavaScript - Inquiry
I am attempting to add a description that appears in the AutoComplete Menu for various functions as can be seen with many of the built in functions/methods for a Javascript file. How would I go about doing so? So far I have attempted creating a description.xml file for one of my JavaScript Files and put the file in the same directory with my JavaScript files (./Scripts/). Is there a process I need to perform to actually import this file into the project? Also, assuming this description.xml file can perform the my desired action, can it be used to add descriptions to functions/methods for multiple JavaScript files? I would assume this is by having multiple of the <Script> tags in the xml, though want to confirm before further proceeding down this route. Below are images of what I am trying to accomplish, in case I am going down the wrong route entirely: Current state: Desired State: I have also attached the description.xml file I am using in attempting this. Please let me know if any additional information is required!Solved129Views0likes9CommentsSmartBear Test Extension manual installation
I want to setup Test complete on our Azure cloud machine, since it do not have internet access i followed the steps in the below link to install SmartBear Test Extension manually https://support.smartbear.com/testcomplete/docs/app-testing/web/general/preparing-browsers/chrome-extension.html?sbsearch=edge%20browser%20extension Issue i am facing is Edge and chrome browser SmartBear Test Extension is getting installed only for my user id and if i login using Test account, the Smart bear extensions are not available. Anyone else faced similar issue? I am not sure if i am missing something when manually adding the SmartBear Test Extension.458Views0likes3Commentschanging dropdown menu field for every testing
Hi Guys, what I want the system to do: I will check a field, it is a dropdown menu, and if this field is for example A, I should select another option for example B for this field from the dropdown list. Or if this field is B I should change it to A so how can I do it with scripting? Do you have an idea? I could have not found the correct codes for this:( For example in one test the field contains A and you should change it to B, than for the next time the field is B and you should change it to A.410Views0likes1Commentcheck points for changeable values
Hey Guys, I have a question about property checks. During my testing I want to check the date which is always changing from day to day or the name of my document which is also changing according to the date. So which kind of property check I can use for? Or how can I manage it with phyton scripts? Could you pls help me?Solved272Views0likes3CommentsUndefined folder created
It creates an undefined folder only. Inside Undefined we got Manual and inside Manual we got time stamp. The main problem is the first folder Undefined. Could anyone please help me? function Test() { var currentDateAndTime = aqDateTime.Now(); var currentTime = aqDateTime.Time(); var currentDate = aqDateTime.Today(); var projectName = ProjectSuite.Variables.projectName; var testtype = ProjectSuite.Variables.testtype; var timestamp = aqDateTime.Now(); //currentDate + currentTime; if(testtype == "Manual") { ProjectSuite.Variables.buildnumber = aqConvert.DateTimeToFormatStr(timestamp, "%m%d%Y_%H%M%S"); } var folderPath = "E:\\Results\\" + projectName + "\\" + testtype +"\\" + ProjectSuite.Variables.buildnumber + "\\"; //var folderPath = Project.Variables.resultpath; // Check if the folder already exists //if (!aqFileSystem.Exists(folderPath)) { // Create the folder //if (aqFileSystem.CreateFolder(folderPath)) { // Log.Message("Folder created successfully: " + folderPath); // } else { //Log.Error("Failed to create folder: " + folderPath); // } //} else { // Log.Warning("Folder already exists: " + folderPath); //} aqFileSystem.CreateFolder(folderPath); //folderPath = folderPath + "\\" Log.SaveResultsAs(folderPath, lsXML, true, 1); // Files are created in the Project1 folder }Solved286Views0likes5CommentsChrome driver not working with TestComplete
TestComplete is not downloading the Chrome driver automatically so I put the webdriver manually in C:\ProgramData\SmartBear\WebDrivers\chrome and I am getting this error: TestComplete failed to download the needed WebDriver. You can download the chrome driver manually and put it in the <ProgramData>\SmartBear\WebDrivers\chrome folder. My TC version is latest: 15.56.2.7 x64 My Chrome web browser version is: 117.0.5938.132 (64-bit) But I am trying to launch Chrome headless via: function launchHeadlessBrowser() { var server = "localhost"; var capabilities = { "browserName": "chrome", "screenResolution": "1920x1080" }; Browsers.RemoteItem(server, capabilities).Run(Project.Variables.url); }Solved720Views0likes6CommentsTesting with text files
Hi, i was wondering if anyone has tried testing with log files. im creating a test that looks over text files and put a parameter if the logfile is less than or greater than the value put. this is the code i have so far but it keeps giving me an error with the script im making. Any thoughts or ideas on how i can make this happen? import sys import os import aq def read_text_file_and_test(file_path): try: with open(file_path, 'r') as file: if __name__ == "__main__": if len(sys.argv) != 2: print("Usage: python test_script.py <path_to_text_file>") sys.exit(1) text_file_path = sys.argv[1] if not os.path.isfile(text_file_path): print("The provided file does not exist.") sys.exit(1) read_text_file_and_test(text_file_path)545Views0likes6Comments