cancel
Showing results for 
Search instead for 
Did you mean: 

TestExecute Asynchron action fail on VM

SOLVED
Highlighted
Occasional Contributor

TestExecute Asynchron action fail on VM

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.

 

Any idea?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Occasional Contributor

Re: TestExecute Asynchron action fail on VM

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.

View solution in original post

12 REPLIES 12
Highlighted
Community Hero

Re: TestExecute Asynchron action fail on VM

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.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Highlighted
Occasional Contributor

Re: TestExecute Asynchron action fail on VM

Here is the function. I don't think is something wrong with it, since on TestComplete is doing well.

 

function ExportDivision

begin
TerminateAction:=aRunAsyncAction(bExportaDiv, 2, '', false, ConfAc);
comboxFileNameExpDiv.SetFocus;
comboxFileNameExpDiv.keys(PathName);
bSaveExportFileDiv.keys(' ');
bConfirmYesReplaceFileDiv.keys(' '); --it will run this line and at the next line will fail
CheckAction(TerminateAction,true);
end;

Highlighted
Community Hero

Re: TestExecute Asynchron action fail on VM

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.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Highlighted
Occasional Contributor

Re: TestExecute Asynchron action fail on VM

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;
begin
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
end;

Highlighted
Occasional Contributor

Re: TestExecute Asynchron action fail on VM

This is CheckAction function.

function CheckAction(aAction :oleobject, bWaitToFinish : boolean = false) :boolean;
begin
if aAction.Completed then begin
result := false;
exit;
end;
while ((not aAction.Completed) and (bWaitToFinish)) do BuiltIn.Delay(200);
result := true;
end;

Highlighted
Community Hero

Re: TestExecute Asynchron action fail on VM

That's not the CheckAction method... that's the one you said errors, right?  


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Highlighted
Community Hero

Re: TestExecute Asynchron action fail on VM

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...  


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Highlighted
Community Hero

Re: TestExecute Asynchron action fail on VM

Hi,

 

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.

Most of scripting languages (including DelphiScript) are synchronous. (Funny case with Javascript : while it was created as asynchronous one, practically all test frameworks force it to synchronous mode 🙂 )

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.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
Highlighted
Occasional Contributor

Re: TestExecute Asynchron action fail on VM

Hi Alex,

 

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.

New Here?
Join us and watch the welcome video:
Top Kudoed Authors