Skip to content

search for HeadingLevel throws exception #4935

@SamBent

Description

@SamBent
  • .NET Core Version: (e.g. 3.0 Preview1, or daily build number, use dotnet --info) 6.0.100-preview.7.21373.8
  • Windows version: (winver) all
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: no (feature not included in 4.8)
  • Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? no
  • Security issues and bugs should be reported privately, learn more via our responsible disclosure guidelines.

Problem description:
Use WPF UI Automation Client stack to search for an element with a certain value for the new HeadingLevel property. The first step is to create a Condition:

PropertyCondition condition = new PropertyCondition(AutomationElement.HeadingLevelProperty, AutomationHeadingLevel.Level3);

(The next step would be a call like element.FindFirst(TreeScope.Descendants, condition), but I can't even get that far.)

Actual behavior:

Exception thrown: 'System.ArgumentException' in UIAutomationClient.dll
An exception of type 'System.ArgumentException' occurred in UIAutomationClient.dll but was not handled in user code
PropertyCondition value for property 'AutomationElementIdentifiers.HeadingLevelProperty' must be 'HeadingLevel'.

Callstack:

 	UIAutomationClient.dll!System.Windows.Automation.PropertyCondition.Init(System.Windows.Automation.AutomationProperty property, object val, System.Windows.Automation.PropertyConditionFlags flags)	Unknown
 	UIAutomationClient.dll!System.Windows.Automation.PropertyCondition.PropertyCondition(System.Windows.Automation.AutomationProperty property, object value)	Unknown
>	FindHeadingLevel.dll!FindHeadingLevel.MainWindow.MainWindow() Line 14	C#

Expected behavior:
No crash.
(Note that the error message refers to a non-public type "HeadingLevel".)

Minimal repro:
FindHeadingLevel.zip

Metadata

Metadata

Assignees

Labels

AccessibilityAn issue related to accessibility enhancements or blockers.BugProduct bug (most likely)urgentstatus: This issue needs immediate attention

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions