CodedUI : PropertyNames.ControlName doesn't wo

2019-08-09 06:37发布

问题:

I'm searching for a customcontrol in a generic way, so I can re-use the function to find other customcontrols that match this one.

Screenshot of the properties

It has a Name and a ControlName. The name property will not always be filled in correctly, the ControlName will be!

When I look for the customcontrol like in the code below, he will locate and perform the requested actions.

WinGroup group = new WinGroup(this.window); group.SearchProperties.Add(WinGroup.PropertyNames.Name, strGroupName, PropertyExpressionOperator.Contains); group.SearchConfigurations.Add(SearchConfiguration.NextSibling);

When I change the PropertyNames to ControlName, he will not locate the control! Which completely surprises me, because it is also unique.

What can be the cause of this? Am I missing something or am I doing something wrong?

Just to be safe, can PropertyNames.ControlName be used to find objects?

Regards, Leslie

回答1:

The question has been posted quite a bit of time ago, but I guess the answer may still be relevant to someone.

I'd suggest trying the following code:

group.SearchProperties.Add("ControlName", "NameOfYourControlNameProperty");



回答2:

ControlId is not a searchable property anyway. CodedUI is just about the most useless POS I've ever seen.