Test error after rerun tests

Originally posted by MichalinaK on February 19, 2025

Hi,

I am testing desktop application in TestComplete. When I open TestComplete and run my test suite all tests are pass. But when I rerun this suite there is some inexpected error. When I colse TestComplete and open this again everyhing is OK, tests pass. What could be the causes?

Originally posted by rraghvani on February 19, 2025

Can you provide more details, as “unexpected error” does not really give us much information to work from!

What version of TC are you using? What scripting language are you using? How are you opening your application? What’s the actual error message?

Originally posted by Hassan_Ballan on February 19, 2025

You need to provide more details, for starter what does the error message state? Screen shot or log complete entry.

Originally posted by scot1967 on February 19, 2025

A complete guess as we don’t have anything to go on. Are you using project or suite variables?

https://support.smartbear.com/testcomplete/docs/testing-with/variables/collections/project-and-project-suite/about.html

Project and project suite variables can be temporary and persistent. You create them in the appropriate sections of the Variables page of the project or project suite editor. Persistent variables store their values between test runs. This way, you can share data between test sessions. Variables of the Object, Table, and DBTable types cannot be persistent.

**Note:**Use persistent variables carefully. When a test run starts, the variable will have the value stored during the preceding test run rather than its initial value and this may cause your test to fail.

Originally posted by MichalinaK on February 20, 2025

For example: “RuntimeError: The object does not exist” in Log.CreateFolder(name) function. This is first step of test.

Originally posted by rraghvani on February 20, 2025

What value are you passing in for “name”?

Originally posted by scot1967 on February 20, 2025

For example: “RuntimeError: The object does not exist” in Log.CreateFolder(name) function. This is first step of test.

Here nameis a variable. This should be a string like “Some Folder Name” or a string variable. Log.Message(name); or set a watch on the variable and let us know what you see. :slightly_smiling_face:

Originally posted by Hassan_Ballan on February 20, 2025

You will need to debug your code to find out the value of “name” on first time and second time run. From your description it would seem that on first time run the value is set to something valid, and later on value is changed to become invalid for second run.

Maybe also you can provide the code in question to look at.

Originally posted by MiguelAlvarez on March 04, 2025

Hi, I get the same error but when calling.

Log.Message("The running state is the one expected!")

It throws the runtimeeerror “The object does not exist” instead of returning None.

from a function inside a BDD @given bining.

This is my BDD Given binding

@given("that the Deidentification tool is not running")
def check_deidentification_tool_is_not_running():
  if application_manager.check_application_isrunning("DeId.GUI", False):
    Log.Message("Application is not running")
  else: 
    if Sys.WaitProcess("DeId.GUI",1000).Exists:
      Sys.Process("DeId.GUI").Close()
      while Sys.WaitProcess("DeId.GUI",1000).Exists:
        aqUtils.Delay(1000)
      if application_manager.check_application_isrunning("DeId.GUI", False):
        Log.Message("Application is not running")
      else:
        Log.Message("Expected result is not met")

Inside of check_application_isrunning is where I get the error, this my check_application_isrunning function

def check_application_isrunning(app_name, expected_state):
  cmd_command = 'powershell "gps | where {$_.MainWindowTitle } | select Description'
  processes = subprocess.Popen(cmd_command, shell=True, stdout=subprocess.PIPE)
  running_processes = []
  for line in processes.stdout:
      if line.rstrip():
          running_processes.append(line.decode().rstrip())
                    
  app_currently_running = app_name in running_processes
  
  if app_currently_running == expected_state:
    Log.Message("The running state is the one expected!")  ##### This is where the runtimeerror happens
    return True
  else:
    Log.Message("The running state is the NOT one expected!")       
    return False

I’m using Testcomplete Version 15.72.60.7 x64 and my project is in python.

I believe this is a bug in testcomplete and here is my reasoning why: I’ve gotten this error before when trying to use the testcomplete property Project.Path. I have to restart my test three times for it to work on the fourth time. I should be able to call Project.Path from anywhere no? Well when I hit this issue and evaluate only “Project.Path” with the debugger I get the runtime error the object does not exist.

Here’s something interesting: When I call Project.Path (or Log.Message) before I get inside the function that uses it, there is no issue, but when it gets called from inside the function that uses it there is an issue. Samething with Log.Message:

Picture Caption: Debug evaluation of Log.Message(somestring) before going into function(works)

Picture Caption: Debug evaluation of Log.Message(somestring) after going into function(doesn’t work)

I managed to work around it by passing Project.Path as a parameter to the function that uses its value, but now I’m having the same issue with Log.Message, so definitely a testcomplete bug unless there are rules about where you can and can’t use it, but like I said if I just retry (restart a run in my BDD feature file) 3 times is works on the fourth time.

Picture Caption: Debug evaluation of Log.Message(somestring) after going into function(works after restarting feature file run a couple times)

Are testcomplete properties e.g. Project.Path and functions e.g. Log.Message always available or could there be some issue with the order the python interpreter loads the class into memory, maybe sometimes these TestComplete properties and methods are not ready for the interpreter at load time?

Thanks

Originally posted by rraghvani on March 05, 2025

When using Python, there are specific requirements you need to follow, see https://support.smartbear.com/testcomplete/docs/scripting/specifics/python.html

I also suggest you run your PowerShell command using https://support.smartbear.com/testcomplete/docs/testing-with/advanced/using-external-functions/running-powershell-scripts.html - as the subprocess command spawns a new process, and TC doesn’t support multithreading.

Originally posted by MiguelAlvarez on March 05, 2025

All my pyton tests are part of the “Scripts” folder. Is there a way to include the python package from testcomplete that has Log and Project into my scripts? That could be a workaround for this testcomplete bug.

Originally posted by MiguelAlvarez on March 05, 2025

Same situation as this person RuntimeErrors after upgrading to 15.68.8.7 | SmartBear Community It’s also happening to me, hopefully they fix it soon

Originally posted by jrussell on March 19, 2025

I am having similar problems. I put a single test in an execution plan group, set the count to 5 so it will run the same test 5 times. after 4 times, it stops with a “RuntimeError: The object does not exist.” I have seen this many times in different parts of our tests and have not been able to figure out the cause. I have been leaning towards a problem with Event Controllers, but it does not happen consistently enough for me to pinpoint anything in particular. I am using version 15.71

Originally posted by caitlinrich on March 19, 2025

When identifying desktop applications and objects, TestComplete uses the properties of the object and Windows processes to identify and recognize objects. If your test runs the application executable each time it runs a test, you may have issues if the application is already open on your system. If the application is already open, TestComplete will open a second instance, which will make it difficult to recognize and access objects.

The best practice is to make sure, when recording tests, that your application starts and ends in the same state for a given test. If TestComplete is having trouble recognizing objects, the first thing I’d check is making sure it’s not opening a new instance of the application when you rerun your test.