Forum Discussion

pashooo's avatar
pashooo
Contributor
13 years ago

The object's name changes from time to time

Hello, everybody)



Do smb faced the problem when application's objects change names?

For example I noticed that the same object may have different names at different times.



For example this item: treeview_BA =



               Sys.Process("OptionsWorkshop").WPFObject("HwndSource: MainForm").WPFObject("MainForm").WPFObject("DockPanel", "", 1).WPFObject("DockingManager").WPFObject("ResizingPanel", "", 1).WPFObject("ResizingPanel", "", 1).WPFObject("ResizingPanel", "", 1).WPFObject("DockablePane", "", 1).WPFObject("DockPanel", "", 1).WPFObject("BaseSeriesTreeView");



                Sys.Process("OptionsWorkshop").WPFObject("HwndSource: MainForm").WPFObject("MainForm").WPFObject("DockPanel", "", 1).WPFObject("DockingManager").WPFObject("ResizingPanel", "", 1).WPFObject("ResizingPanel", "", 1).WPFObject("DockablePane", "", 1).WPFObject("DockPanel", "", 1).WPFObject("BaseSeriesTreeView");



                Sys.Process("OptionsWorkshop").WPFObject("HwndSource: MainForm").WPFObject("MainForm").WPFObject("DockPanel", "", 1).WPFObject("DockingManager").WPFObject("ResizingPanel", "", 1).WPFObject("rpMain").WPFObject("rpTop").WPFObject("dpSeries").WPFObject("DockPanel", "", 1).WPFObject("BaseSeriesTreeView")






This is the difference:

...WPFObject("ResizingPanel", "", 1).WPFObject("ResizingPanel", "", 1).WPFObject("DockablePane", "", 1)...

...WPFObject("ResizingPanel", "", 1).WPFObject("DockablePane", "", 1)...

...WPFObject("rpMain").WPFObject("rpTop").WPFObject("dpSeries")...



...what may be the reason? I find that name may change after reload application but may stay the same. I cant understand from what it depend...  please share your experience!

3 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Pasha,



    It seems that your tested application uses docking (just like TestComplete http://smartbear.com/support/viewarticle/11346/#Basics). The behavior you are describing can happen if the application's docking layout is changed. When you dock, undock or rearrange panels, the application creates, modifies or destroys intermediate docking containers -- as a result, there are different objects in the middle of the object hierarchy.



    To handle such situations, you can skip dynamic objects and use the FindChild method to locate the target object:

    var DockingManager = Sys.Process("OptionsWorkshop").WPFObject("HwndSource: MainForm").WPFObject("MainForm").WPFObject("DockPanel", "", 1).WPFObject("DockingManager");

    var BaseSeriesTreeView = DockingManager.FindChild("NativeClrObject.Name", "BaseSeriesTreeView", 5);

  • Helen, it seems to me that you know all about TC))

    You help me again!

    Thank you very much/