Forum Discussion

rmnrdi's avatar
rmnrdi
Contributor
7 years ago

compare object

I have a program that I need to check the properties of in two different states. TC only allows one object to be captured by object spy at a time.

 

Is there any way to do a side by side comparison of object properties? Export a list of properties and their values to a file of some type?

 

The only way I'm seeing how to do that now is to do screen shots (usually multiple) and compare them manually.

 

I'd like to be able to capture the properties of an object in one state, change the state and then compare the properties in the that state.

 

Is this currently possible?

 

Thanks,

Rob

  • No additional save, just a refresh of the variable as per below.

     

     

    procedure CompareObjects;
    var
    tracePanel, PropertyNames, CollectionName, tfrmModifyTrace2 : OleVariant;
    begin
    //Get panel object
    tracePanel := Aliases.SettingsNavigator.frmModifyTrace2.VCLObject('Panel3');
    
    // Sets the name of the property collection
    CollectionName := 'TracePanelProps';
    
    // I want it to check all properties, so I leave the property name blank.
    Objects.Save(tracePanel, CollectionName);
    
    tfrmModifyTrace2 := Aliases.SettingsNavigator.frmModifyTrace2;
    tfrmModifyTrace2.MainMenu.Click('Manage|Get Library Trace');
    tfrmModifyTrace2.pnlLibLookup.isLibName.Keys('[Enter]');
    
    tracePanel := Aliases.SettingsNavigator.frmModifyTrace2.VCLObject('Panel3');
    
    Objects.Compare(tracePanel, CollectionName, true, lmMessage);
    
    Objects.Remove(CollectionName); 

     Additionally... there is more information in the error than just "Object Compare error".  Any additional info/text would be useful.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    1) Store the object properties in the first state into some sort of structure.  Could be multiple variables, could be a JavaScript object, could be an array... anything.
    2) Write code to compare the properties of the object AFTER to the stored properties.

     

    That's one possible scenario.

     

    You could also create multiple property checkpoints... run them "before"... and run them "after".

    In short... the answer to your question is... yes, it is possible.  Depends upon what implementation you want to make as to how you will implement it.  I wouldn't use image comparisons for this.

    • rmnrdi's avatar
      rmnrdi
      Contributor

      Thanks for your reply tristaanogre. I guess I should have said:

       

      Is this currently possible with TestComplete? Or. Does TestComplete have a feature that accomplishes this?

       

      I'll look into doing that.

       

       

       

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        The answer to that is... no, not that I am aware of.  Properties of an onscreen object are gathered in real time.  So, to compare the object properties in run time from one point to another requires creating some sort of storage and comparison as described.