flyboy615's avatar
flyboy615
Occasional Visitor
6 months ago
Status:
New Idea

Display any System.GUID property in object explorer as the actual GUID raw value in WPF

We have a situation where the original development team didn't name most of the objects in WPF, they did however add in a property that contains a system GUID. It would help our named mapping enormously if we could reference the value as the raw GUID rather than a series of decoded values.

In the above image, the GUID value has been broken down into a series of sub elements and then seem to have been converted into decimal values. The raw value, as seen below, is the actual GUID value matching the above property as we would like to see it (from Snoop)

What we would like is to have an additional raw value field displaying the complete GUID whenever the object property is of type System.GUID allowing the named mapping to identify the object by this property.

 

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Have you tried to enable MSAA in TestComplete, to see if more objects and properties are exposed?

  • You’re totally right, that’s how the GUID type is represented under the hood inside the Name Mapping component (which is a direct consequence of this:

    ). While technically it should be possible to extend the Name Mapping component within TestComplete so that its string representation is easily accessible, maybe the following workaround would suffice for the time being?

    I assume the HomeItemButton is a class deriving from some kind of a Windows Forms button - for the purpose of example, let’s generalize it and call YourCustomButtonClass. Your HomeId property (of type System.GUID) will correspond to YourCustomGuidProperty property in our example. Now, if you want to locate it through a string representation of the GUID and click, you cannot use the default “Click” operation in TestComplete. Instead, please add the following script to your test (assuming python syntax):

    def find_button(your_custom_property_value):
      all_buttons = Aliases.Sample.HwndSource_MainWindow.MainWindow.FindAllChildren("ClrClassName", "YourCustomButtonClass", 200)
      for b in all_buttons:
        if b.DataContext.YourCustomGuidProperty.ToString() == your_custom_property_value:
          btn1 = b
          btn1.Click();
          return

    Let’s call the script find_button

    Then, when you wish to click the desired button in the test, add “Run Script Routine” operation, specify the GUID (as a string) as the your_custom_property_value parameter. It should resemble something like this:

    Script will recursively look for your desired element by the string representation of the GUID.

    Alternatively, if the element is not a button and you want to do something different with it, you can create a variable in your TestComplete project and instead of executing Click directly in the Script, you can assign the element to a TC variable from within the script and manipulate/consult the variable in subsequent steps of the test:

    def find_button(your_custom_property_value):
      all_buttons = Aliases.Sample.HwndSource_MainWindow.MainWindow.FindAllChildren("ClrClassName", "YourCustomButtonClass", 200)
      for b in all_buttons:
        if b.DataContext.YourCustomGuidProperty.ToString() == your_custom_property_value:
          Project.Variables.btn1 = b
          return

    Please do not hesitate to contact us further if this does not address your issue or the explanation/example is not clear enough.

    Best regards,
    TestComplete Team