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 Test...
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.
For example: "RuntimeError: The object does not exist" in Log.CreateFolder(name) function. This is first step of test.
Here name is 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. 🙂
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.
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?