Micro Focus QTP (UFT) Forums
Using QTP Automation Object Model to declare object classes - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Using QTP Automation Object Model to declare object classes (/Thread-Using-QTP-Automation-Object-Model-to-declare-object-classes)



Using QTP Automation Object Model to declare object classes - sadafakhan - 07-24-2009

[/u][/b]Hi,

I want to reduce the overhead of declaring objects such as write a 3-line decsription to declare WebEdit before I can use it. I am working on creating a dll in vb.net to do the declarations. Any user can simply refernce this dll in QTP and use the declarations present to simplify the qtp code. However, I cannot get this to work. Any idea on how to do this in vb.net. I created the following file but it is not working in QTP.

VB.net:[b]

Code:
Public Class Class1
    Public Function QTPHelper_Example()
        Dim qtApp As QuickTest.Application
        Dim qtIdent As QuickTest.ObjectIdentification
        Dim qtWebEdit As QuickTest.TestObjectClassIdentification

        qtApp = CreateObject("QuickTest.Application")
        qtIdent = qtApp.Options.ObjectIdentification

        qtWebEdit = qtIdent.Item("WebEdit")

        Return qtWebEdit

    End Function

End Class

[u][/b]QTP:[b][/u]

Set objDLL=DotNetFactory.CreateInstance("ClassLibrary6.Class1","C:\windows\system32\ClassLibrary6.dll")
Set objwebedit=objDLL.QTPHelper_Example()

objwebedit("html id").value = "cnnHeadsrchText"
Browser(browser).page(page).WebEdit(objwebedit).Set "test"
Set objDLL= Nothing