Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
trouble with Class statement / user defined objects
#1
Not Solved
I'm using a Class statement (follows at end) that i'd like to locate outside of the main test, in order to reuse it easier.

If i include the entire statement in the main action, it works fine.

If i do any of the following, i get "class undefined" error when trying to create an instance of it (via: Set shopper = new User):

1. create a new test called "Classes". Create a reusable action in it called
"UserClass", which contains the Class statement. Call it either via "include call to external action" or "insert copy of existing action".

2. create function library called UserClass.qfl.
Include the Class statement in this qfl, surrounded by:

Sub makeUserClass()
[Class statement]
End Sub

I associate the qfl with the test, then call makeUserClass() before creating new instance.

3. save Class statement variously as UserClass.qfl, UserClass.vbs, User.class. variously use: executeFile; executeGlobal (on a string containing the code).


Code:
Class User
   dim email,_
    fname,_
    lname,_
    ....etc

    Sub Class_Initialize()
        email = "qa" & MonthName(Month(Now)) &_
                   Day(Now) & Year(Now) & Hour(Now) &_
                   Minute(Now)& Second(Now) & "@mydomain.com"
        fname = RandomWord(3,10)
        lname = RandomWord(3,10)
        ....etc        
    end sub

    Sub saveUser()
        DataTable.Value("email", "Global") = email
        DataTable.Value("fname", "Global") = fname
        DataTable.Value("lname", "Global") = lname
        ....etc
    end sub  
End Class



any help on how to clean this up appreciated.

mike

(QTP 9.2)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  DP Encapsulation Within Class Object TheGlovner 2 1,593 10-12-2018, 02:11 PM
Last Post: TheGlovner
  UFT 12.02 Compatibility for IE 11.0 : Fail to identify the defined Object Amruta_121 9 10,474 01-11-2016, 12:45 PM
Last Post: vinod123
  Dynamic obj rep - get text in the class (html) marcio cravo moreira 0 2,035 05-26-2015, 06:58 PM
Last Post: marcio cravo moreira
  can class be a variable in DP wyrdo 1 2,348 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,661 08-07-2013, 01:26 PM
Last Post: anil2u

Forum Jump:


Users browsing this thread: 1 Guest(s)