Cast Object as WPF Object
i'm trying to use Testcomplete standard functions with an object received directly from a function call to a WPF/.net application on a request, rather than going through the usual Namemapping/Search tree.
It looks like this:
var obj = Aliases.App.Main.GetControl();
This obj can access all .net properties and methods just fine.
E.g. for a Button i can call
However, if the button was received through namemapping like this:
var NMobj = Aliases.App.Main.ButtonTest;
I can also access e.g:
Which doesn't work with "obj" because "this object doesn't support this method".
So my question is: is there any possibility to tell Testcomplete, that "obj" is a WPFButton, to make all the usual methods available?
I tried FindChild with some of the attributes of "obj", to receive a Testcomplete object, which works, but it takes around 10 seconds for every control, which is not acceptable.
Any better possibility?
Thanks a lot!
Solved! Go to Solution.
> is there any possibility to tell Testcomplete, that "obj" is a WPFButton
No, this is not possible.
If I got it right, .GetControl() is a method of the tested application that returns native .Net object. WPFButton (and others a-like) is TestComplete's wrapper over the .Net object identified via the means provided by TestComplete.
10 seconds for every control seems weird and my guess is that you should optimize either your NameMapping/Aliases or the way how .FindChild is used. (For example, the search that starts at application level and searches for the object that is too deep in the wide objects tree might be slow. But the preliminary search for one or several intermediate parent containers for the same object might speed up the search quite significantly.)
/Alex [Community Champion]
[Community Champions] 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 Champions]
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 Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
thanks a lot for your answer.
It's unfortunate, that casting the object would not work.
FindChild probably takes 10 seconds, because the target object isn't mapped at all and it's a large application with thousands of objects and many hierarchy levels. Visible at once however maybe few 100.
This method with getting the object from .net within few milliseconds was a new approach so we don't need the namemapping, which is just a massive bloat of work to create and maintain with so many objects and changing hierarchy structures.
It's all handwork(drag here, click here, choose names, choose properties...) and hierarchies that are sometimes there and sometimes not doesn't work well with the namemapping either, so we require something better.