当我尝试获取Toolstrip元素时
ToolStrip toolStrip = StartApplication.Window.Get<ToolStrip>(SearchCriteria.ByText("Toolbar"));`
发生此错误:
错误:无法获取ControlType =工具栏,名称=工具栏
工具栏属性为:
- 姓名:&#34;工具栏&#34;
- ControlType:UIA_ToolBarControlTypeId(0xC365)
- LocalizedControlType:&#34;工具栏&#34;
- IsEnabled:true
- IsOffscreen:false
- IsKeyboardFocusable:true
- HasKeyboardFocus:true
- LegacyIAccessible.Name:&#34;工具栏&#34;
- LegacyIAccessible.Role:工具栏
- (0x16)LegacyIAccessible.State:专注,可聚焦(0x100004)
答案 0 :(得分:1)
尝试使用ByAutomationId
作为搜索条件。
举个例子:
ToolStrip toolStrip = StartApplication.Window.Get<ToolStrip>(SearchCriteria.ByAutomationId("Toolbar"));