Micro Focus QTP (UFT) Forums
Is there a way to create dynamic objects by declaring the type of object as parameter - 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: Is there a way to create dynamic objects by declaring the type of object as parameter (/Thread-Is-there-a-way-to-create-dynamic-objects-by-declaring-the-type-of-object-as-parameter)



Is there a way to create dynamic objects by declaring the type of object as parameter - lotos - 10-11-2017

Hey guys, need some ideas about creating dynamic functions and objects which could be used across different platforms, e.g. web, java, windows, etc...
Below is an example of what I am trying to achieve (not even sure this would be possible). So for e.g. I have a check function which in case = true then reports Pass, otherwise reports Fail.
Code:
Public Sub ObjByTitle_Exist(objType, objTitle)
    Set objDesc = Description.Create  
    objDesc("micclass").value = objType
    objDesc("title").value = (objTitle & ".*")


    If objType(objDesc).Exist(5) Then
        ''' Report Pass
    Else
        ''' Report Fail
    End If
End Sub


The intention of such a thing is to be used across different platforms where when using it I just throw in the object type and the system will identify it and do whatever is needed or possible with that specific object.

Then I am looking to use it in this way:
Code:
'in Java:
ObjByTitle_Exist "JavaDialog", "DialogTitle"

'in Windows:
ObjByTitle_Exist "SwfDialog", "DialogTitle"

Another example would be for e.g. I have an SwfButton and a WebButton - no I am trying to access any of those buttons by using a function like the one above - I could create 2 different function for each object type, but this would extend the framework way too much. Any ideas if kind of a combined framework could be created or one to be used across multiple environments would be great?!


RE: Is there a way to create dynamic objects by declaring the type of object as parameter - Ankur - 10-11-2017

I guess you are talking about different applications altogether when you refer to different environments.

Technically yes, it should be possible. I would suggest you to weight the pro-and-cons of doing this by doing a simple POC on a small module in all environments.
  • See if it is helping you get productive.
  • check if maintenance would be easy.
  • How easy will it be to onboard a new team mate in your project.



RE: Is there a way to create dynamic objects by declaring the type of object as parameter - lotos - 10-11-2017

(10-11-2017, 07:41 PM)Ankur Wrote: I guess you are talking about different applications altogether when you refer to different environments.

Technically yes, it should be possible. I would suggest you to weight the pro-and-cons of doing this by doing a simple POC on a small module in all environments.
  • See if it is helping you get productive.
  • check if maintenance would be easy.
  • How easy will it be to onboard a new team mate in your project.

That is true Ankur, two or more different applications with a common piece of framework. If this is technically possible, then how would this be achievable, can you please give an example based on my code above? We're having tons of applications built using different technologies (.Net, Java, Web, etc..). Now some are integrated and there are test cases which are interacting with multiple apps - hence why I am looking for such a solution (common framework) as otherwise I'll have to build some frameworks for each of these application types. Looking to combine those into one.

Thank you.


RE: Is there a way to create dynamic objects by declaring the type of object as parameter - lotos - 11-08-2017

(10-11-2017, 07:41 PM)Ankur Wrote: I guess you are talking about different applications altogether when you refer to different environments.

Technically yes, it should be possible. I would suggest you to weight the pro-and-cons of doing this by doing a simple POC on a small module in all environments.
  • See if it is helping you get productive.
  • check if maintenance would be easy.
  • How easy will it be to onboard a new team mate in your project.

Hi Ankur, any examples here? More detailed ideas, suggestions would help a lot and would be much appreciated.

Thank you.