Running a DelphiScript test on TestComplete 14.30.3743.7 x64 is passing, while running the same script on TestExecute 14 and VM (Windows Server 2016 64-bit OS,16 GB RAM, 4 cores 2.10 GHz), test will failed with Asynchronous object call failed.
Solved! Go to Solution.
It was my mistake; the environments were different, having different databases, which lead to a different behavior of the tested application. So, I cannot assume anymore TesteExecute and TestComplete are acting different, except the play time, which is faster at TE.
With other words, this topic it has no point in my view, and for this specific environment which I mentioned above.
Without knowing what the code is, can't say for sure. Most likely, there's something different on the TestExecute VM that is not accounted for on the development machine, most likely something to do with timing where an object does not exist in time.
Please post the code where the error occured.
Here is the function. I don't think is something wrong with it, since on TestComplete is doing well.
TerminateAction:=aRunAsyncAction(bExportaDiv, 2, '', false, ConfAc);
bConfirmYesReplaceFileDiv.keys(' '); --it will run this line and at the next line will fail
CheckAction is not a TestComplete function I recognize so I'm guessing it's something custom written by you or someone on your team. can you share that code? I'm guessing it's something in there that's causing the failure.
It is a function based on CallObjectMethodAsync TestComplete's method. But again, I don't see a reason to pass in TC and fail in TE.
function aRunAsyncAction(aMainWindow: oleobject; ContainerType: integer; aActionName: string,
var w: oleObject;
case ContainerType of
0 : w:= Runner.CallObjectMethodAsync(aMainWindow.commandManager.Commands.Item[aActionName], 'Execute');
1 : w:= Runner.CallObjectMethodAsync(aMainWindow.stateCM.Commands.Item[aActionName], 'Execute');
2 : w:= Runner.CallObjectMethodAsync(aMainWindow, 'PerformClick');
3 : w:= Runner.CallObjectMethodAsync(aMainWindow, 'keys',' ');
4 : w:= Runner.CallObjectMethodAsync(aMainWindow, 'keys',aActionName);
5 : w:= Runner.CallObjectMethodAsync(aMainWindow, 'BringToFront');
6 : w:= Runner.CallObjectMethodAsync(aMainWindow, 'PerformClick',aActionName);//don't change it
This is CheckAction function.
function CheckAction(aAction :oleobject, bWaitToFinish : boolean = false) :boolean;
if aAction.Completed then begin
result := false;
while ((not aAction.Completed) and (bWaitToFinish)) do BuiltIn.Delay(200);
result := true;
That's not the CheckAction method... that's the one you said errors, right?
OK... so, my DelphiScript is a bit rusty these days... but your function for running an Asynchronus action doesn't appear to return anything. So, you're assigning that TerminateAction to the result of aRunAsynchAction which doesn't appear to return anything. So, you're then trying got check the result of something that is empty... at least that's how it reads to me. So, I'm actually surprised it runs at all.
However, I'm assuming that something is missing in the code you pasted here so my next suspicion is that something is happening out of time with regards to your Asynch calls. TestExecute tends to run things a LOT faster than TestComplete at times... so, you may be trying to check the result of an Asynchronous call that may already be gone and destroyed...
In addition to everything written by Robert:
> function aRunAsyncAction [...]
In a most cases human user works synchronously. Likewise do most of tests.
Actions like PerformClick, Keys, BringToFront are also synchronous.
The primary reason for the .CallObjectMethodAsync() method in TestComplete is to handle cases when some object does not exit its event handler until this event is handled. E.g. when the modal window does not return control until it is closed, causing deadlock when been controlled by test automation software. .CallObjectMethodAsync() method is the only means in this case and this is practically the only case when it should be used.
So, unless you can provide a reason why you are trying to implement asynchronous code in synchronous environment I would recommend you to not use .CallObjectMethodAsync() method and replace it with regular synchronous calls.
Unfortunately, TestComplete won't work without the asynchron method on that specific modal window. On the other hand TestExecute seems not to work with asynchron method for the same modal window. I should probably create different scripts for each testing tool, which if you ask me, is not reasonable.
PerformClick is synchronous for as long as a modal window will not follow, when the case is changing, and an asychron method has to be use.
However, I can understand Robert's explanation that TestExecute is faster than TestComplete at runtime, and this is a reason to "loose" the asynchron object.
It is nothing wrong with the asynchron method I've posted here, since is running for years with TestComplete, with the same script, and on the same desktop application-the trouble is, we've just moved to TestExecute where it seems to be a different environment, and will take a bit more to get familiar with its behavior.