Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DP Encapsulation Within Class Object
#1
Solved: 6 Years, 1 Month, 2 Weeks ago
First post so hopefully this makes sense.

I've been given my first tasks within UFT having moved into a new role (previous experience was mainly using VBA and SQL within the Excel Environment, so have an understanding of classe module objects within the VBA Structure).

I'm keen to use the descriptive programming concept within the cases being designed so we can encapsulate the object recognition in the class itself, not sure if this is doable though.

Code:
option explicit

Function ApplicationClassCreation
   ApplicationClassCreation = new Application
End Function

Class Application
    
    Public Window
    
    Sub Initialise
        
        Set SPICEWindow = Description.Create
        Window("Class") = "SwfWindow"
        Window("swfname") = "ShellUI"
        Window("regexpwndtitle") = "SPICE (Environment: Syst)"
        Window("is owned window") = False
        Window("is child window") = False
  
    End  sub
    
    
End Class

The above is an extract of the external function library being used to host the class code.

The structure of the program is:
  -High Level Test Script (which loads)
      - Pre Processing Function Library (Which sets up various file paths according to the local install of the git directory, which also loads)
          - Application Class
The application class once instantiated in the Pre Processing Function Library is then passed back up to high level test script for use.
I was then calling the Initialisation routine from the high level test script thinking this would create the window object that I could reference from the class object, but none of these lines of code work.

Hoping someone can shed some light on this and if what I'm doing is possible within UFT.

Thanks.
Reply
#2
Solved: 6 Years, 1 Month, 2 Weeks ago
Realise that I had made a school-boy error with the above code, so while I can get the lines of code to run now, the created object appears to be of a "collection" type (I'm assuming this because the only methods available to it are Add, Item, Count and Remove which are obviously collection methods).

My expectation was that it would create a window object and give me access at runtime to the methods of a window (.exists).

Here is the updated code:


Code:
Function SpiceClassCreation
    set SpiceClassCreation = new SPICEApplication
End Function

Class SPICEApplication
    
    Public SPICEWindow
    
    Sub Initialise
        Set SPICEWindow = Description.Create
        SPICEWindow("Type").value = "SwfWindow"
        SPICEWindow("swfname").value = "ShellUI"
        SPICEWindow("regexpwndtitle").value = "SPICE (Environment: Syst)"
        SPICEWindow("is owned window").value = False
        SPICEWindow("is child window").value = False
        check = SPICEWindow.Exists
    End  sub
    
    
End Class
Reply
#3
Solved: 6 Years, 1 Month, 2 Weeks ago
Another school-boy error it seems.

I hadn't realised when using descriptive programming you still need to encapsulate your object within the keyword of the class it denotes.

I've altered the check to:

check = swfwindow(SPICEWindow).exist

And it now works exactly as I thought it would.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Dynamic obj rep - get text in the class (html) marcio cravo moreira 0 2,127 05-26-2015, 06:58 PM
Last Post: marcio cravo moreira
  Cannot find the "[ WebEdit ]" object's parent "[ Browser ]" (class Browser). Verify t Divya Roopa 1 8,474 03-11-2014, 12:13 PM
Last Post: devarapallliramana
  can class be a variable in DP wyrdo 1 2,475 08-07-2013, 01:33 PM
Last Post: anil2u
Sad QTP Script | how to get object of some open window just using its class type,Java sophia.sabir 1 8,868 08-07-2013, 01:26 PM
Last Post: anil2u
  Use of Class Concept in QTP sshukla12 6 15,122 12-23-2011, 03:44 PM
Last Post: sshukla12

Forum Jump:


Users browsing this thread: 2 Guest(s)