Micro Focus QTP (UFT) Forums
Need Guidance to Identify Object's Class in QTP - 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: Need Guidance to Identify Object's Class in QTP (/Thread-Need-Guidance-to-Identify-Object-s-Class-in-QTP)



Need Guidance to Identify Object's Class in QTP - Darshan Doshi - 07-10-2008

Hi,

I need a quidance in QTP for the following scenario in the project.
I am not aware for it's possibility to do so. If not, guide me for any other procedure to follow.

Scenario:

Application selects the program from the list and based on that program next page ask for an input for various questions of different objects.

Example:

First Time
- - - - - - - - Program I is selected.
- - - - - - - - - - - - -Inputs required for an objects - - - - - - - - - - name in object repository
- - - - - - - - - - - - - - - - - 1. TextBox - - - - - - - - - - - - - - - SC_1-Q_1
- - - - - - - - - - - - - - - - - 2. TextBox - - - - - - - - - - - - - - - SC_1-Q_2
- - - - - - - - - - - - - - - - - 3. CheckBox - - - - - - - - - - - - - - SC_1-Q_3
- - - - - - - - - - - - - - - - - 4. ComboBox - - - - - - - - - - - - - -SC_1-Q_4
- - - - - - - - - - - - - - - - - 5. TexBox - - - - - - - - - - - - - - - SC_1-Q_5

Second Time
- - - - - - - - Program II is selected.
- - - - - - - - - - - - -Inputs required for an objects - - - - - - - - - name in object repository
- - - - - - - - - - - - - - - - - 1. CheckBox - - - - - - - - - - - - - SC_1-Q_1
- - - - - - - - - - - - - - - - - 2. TextBox - - - - - - - - - - - - - - SC_1-Q_2
- - - - - - - - - - - - - - - - - 3. TextBox - - - - - - - - - - - - - - SC_1-Q_3

Note: Object Repository name provided in generic format since I am calling each object inside nested loop.

Here I planned to create reusable functions as flow of the scenario is same and only behaviour at part of the application changes.
I can count the number of inputs to be provided since it is inside a table.
Currently I kept it into the loop (Since my current question carries only textbox - which is apart from above example).

Now I feel that anyhow if I can find which object is appearing for the perticular loop thorugh identifying its class type then dynamically I can set the values.
So can it be possible for me to find out the class type from object name like SC_1-Q_1 or so.

In such case my code at expet view changes as we do for dynamic object name like:
Code:
Browser(...).Page(...).WebEdit("SC_" & scno & "-Q" & qno).set Text


Similar way is it possible for object name like:

Code:
Object = FindOneObjectOfClass {TextBox, CheckBox, ComboBox}

'for first object SC_1-Q_1 and later in loop for other objects too

Code:
If Object is TextBox or CheckBox Then
              Browser(...).Page(...).Object("SC_" & scno & "-Q" & qno).set Text
           Else If Object is ComboBox Then
              Browser(...).Page(...).Object("SC_" & scno & "-Q" & qno).select Text
           End If

In other words, as we can replace Object Name with an Varialbe name, in same fashion can we replace Class Name?
If not any alternative procedure Which I can follow?