I’m just curious – QTP has the functionality to call .NET objects directly via the DotNetFactory object, see this article from learnqtp.com, but it can also call objects through COM (see this post from Joe Colantonio). What would the advantage be in using one method over another? So far as I can tell, both methods have similar restrictions on the objects that can be called (no constructors with parameters, etc.), but I’m wondering about deeper details.
Thanks!
First of all one of your assumptions is wrong,
DotNetFactorydoes support calling constructors with parameters (that’s what the optionalargsparameter is for).The
CreateObjectfunction is built in for VBScript, since QTP tests are written in VBScript this functionality comes for free and is not technically a QTP feature. TheDotNetFactoryis part of QTP and allows creating .NET objects even if they are not COM visible.If you have a .NET object which is COM visible you can choose which method you’re more comfortable with but if you have a COM object you must use
CreateObjectand if you have a non-COM visible object you must useDotNetFactory.