Monday 25 March 2013

Dotnetfactory.createinstance in QTP

In QTP, you can use dotnetfactory object to access .net objects. You must have .net framework installed in your system before you use createinstance method.

It enables you to create an instance of a .NET object, and access its methods and properties.
Description
Createinstance method returns a COM interface for a .NET object.

Syntax
Set myobj = DotNetFactory.CreateInstance (TypeName [,Assembly] [,args])

Here 
Typename - any type name that .net framework provides example - System.Environment

Example
The following example uses the CreateInstance method to create a object of a system environment type

Set obj = Dotnetfactory.CreateInstance("System.Environment")
print obj.MachineName


Set obj = Dotnetfactory.CreateInstance("System.Math")
print cstr(obj.Abs(-12))      
    




No comments:

Post a Comment

Please Leave your reply. We value your feedback and inputs

Best QTP Books

Everything About QTP

Hello Friends,
You can find QTP study material, Multiple choice questions (mcq), QTP question bank, QTP question papers, QTP notes, QTP questionnaire, scenario based QTP interview questions, QTP tutorial and QTP training on this site.

If you are a fresher or experienced QTP professional with (1/2/3/4) years of experience, this blog is just for you.