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:
GUID - Win32 apps). 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
Related Content
- 6 years ago
- 4 years ago
- 12 years ago