Forum Discussion

niravp's avatar
11 years ago

How to get index of dynamic WPFObject

Below is the full object name... 

   

Sys.Process("Application1").WPFObject("HwndSource: RootWindow").WPFObject("RootWindow").WPFObject("Grid24").WPFObject("ContainerGrid").WPFObject("rootInstantViewContainer").WPFObject("ContentPresenter", "", 5).WPFObject("RadBusyIndicator", "", 1).WPFObject("Grid23").WPFObject("ContentPresenter", "", 1).WPFObject("NotificationCenterContainer", "", 1).WPFObject("NotificationCenterContainerGrid")



Index numbers which are in bold they are always change, so how to get index value of those WPFObject on run time?

2 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Nazz,


     


    Actually, identifying an object by index isn't a very reliable approach. You'd better choose another way to obtain the desired object. For example, you can use the Find method to search for the target object by using several properties whose values never change. Details...


     

  • leandropoblet's avatar
    leandropoblet
    Frequent Contributor
    Hi Nazz,



    Since you're working with grids I'd suggest you to use the controls to handle grids, which depending on how they've been developed would be very usefull. Take a look here: http://support.smartbear.com/viewarticle/62006/



    Something else: if you try finding the objects as Tanya suggested, you can use wilcards to replace the indexes:



    Sys.Process("Application1").WPFObject("HwndSource: RootWindow").WPFObject("RootWindow").WPFObject("Grid24").WPFObject("ContainerGrid").WPFObject("rootInstantViewContainer").WPFObject("ContentPresenter", "", *).WPFObject("RadBusyIndicator", "", *).WPFObject("Grid23").WPFObject("ContentPresenter", "", *).WPFObject("NotificationCenterContainer", "", *).WPFObject("NotificationCenterContainerGrid")



    Hope this helps you,

    Leandro