Forum Discussion

eliaralva's avatar
eliaralva
Occasional Contributor
14 years ago

HELP!: How to Create a TObject (Delphi) in Test Complete 7 ?

Hello, I want to know how I can create a TObject from Test Complete, I tried this code but it doesn't work:



(I am working with TC7 and with Delphi 5)



 


procedure Test1;

var obj: Tobject;

begin

  obj:= TObject(45);

end



Thanks in advance,



Elia.


Test1;

 

6 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    DelphiScript in Test Complete is a non-typed language.  Everything is an OleVariant so you can't declare a variable as type TObject and use it as such.



    The work around for creating customer objects is to use the ODT.Classes object structure for creating custom classes and objects
  • eliaralva's avatar
    eliaralva
    Occasional Contributor
    Thanks Robert for your quick response, can you please provide some example using ODT, thank you!

  • Hi Elia,





    Examples can be found in the '<TestComplete Samples>\Scripts\ObjectDrivenTesting\Simple ODT' and '<TestComplete Samples>\Scripts\ObjectDrivenTesting\ObjectDrivenTesting' folders. Note that on Windows 7, Windows Vista and Windows Server 2008, TestComplete samples are located in the "<Users>\Public\Documents\TestComplete 7 Samples" folder. On other operating systems, the samples reside in the <Documents and Settings>\All Users\Documents\TestComplete 7 Samples folder.
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    A very simple example would be something like this.





    procedure DemoObject;



    var

        NewClass;

        NewObject;



    begin

    NewClass := ODT.Classes.Declare('NewClass');

    NewClass.AddProperty('Property1');

    NewClass.AddProperty('Property2');

    NewObject := ODT.Classes.New('NewClass');

    NewObject.Property1 := 'This is my first property';

    NewObject.Property2 := 'This is my second property';

    Log.Message('This demonstrates my object: Property 1 - ' + NewObject.Property1);

    end;
  • scsvel's avatar
    scsvel
    Frequent Contributor
    Another clarification guys..

    If objects created using these type custom classes and objects while app development, will these objects identified as open apps objects in TestComplete as VCLObject?



    I have an app which have all objects as with custom class name and after recording it shows like

    sys.process("myapp").window("className","").window("className","").window("className","") etc for all child objects from the first parent window. Nothing shows as VCLObject or CLXObject.

    Any idea about this?



    Thanks...

  • Hi Elia,





    The VCLObject method lets you access the specified object of an Open Application that was created in Delphi and C++Builder using VCL classes, the CLXObject - using CLX classes. Please clarify what IDE and framework were used to create the application.