我正在测试一个 WPF 桌面应用程序,我想在其中检查当前元素的下一个(或上一个)元素的名称字段的值。
示例:(element1) 数量:(element2) 100
在这里,我想检查 Quantity (element1) 的下一个元素 (element2) 是否为 100。
上述场景的以下代码为 null 或空。
var element = driver.FindElementByName("Quantity");
string qty = element.GetAttribute ("Next"); // Next attribute value is 100 in Inspect.exe
我做错了吗?或者这种情况还有其他方法吗?
[检查工具-详情]
How found: Mouse move (269,94)
hwnd=0x00000000002D1650 64bit class="HwndWrapper[Prax.exe;;93a825de-2e06-4b56-9205-49c253040049]" style=0x16080000 ex=0x40000
Name: "partattributerev"
ControlType: UIA_TextControlTypeId (0xC364)
LocalizedControlType: "text"
BoundingRectangle: {l:221 t:81 r:340 b:105}
IsEnabled: true
IsOffscreen: false
IsKeyboardFocusable: false
HasKeyboardFocus: false
AcceleratorKey: ""
AccessKey: ""
ProcessId: 18148
RuntimeId: [7.46E4.2498D96]
AutomationId: ""
FrameworkId: "WPF"
ClassName: "TextBlock"
IsControlElement: true
IsContentElement: true
ProviderDescription: "[pid:18148,providerId:0x0 Main(parent link):Unidentified Provider (managed:MS.Internal.Automation.ElementProxy, PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)]"
LiveSettingProperty: Off (0)
IsPassword: false
ItemStatus: ""
ItemType: ""
IsRequiredForForm: false
HelpText: ""
ClickablePoint: {x:280 y:93}
Orientation: 0
LegacyIAccessible.ChildId: 0
LegacyIAccessible.DefaultAction: ""
LegacyIAccessible.Description: ""
LegacyIAccessible.Help: ""
LegacyIAccessible.KeyboardShortcut: ""
LegacyIAccessible.Name: "partattributerev"
LegacyIAccessible.Role: text (0x29)
LegacyIAccessible.State: normal (0x0)
LegacyIAccessible.Value: ""
IsAnnotationPatternAvailable: false
IsDragPatternAvailable: false
IsDockPatternAvailable: false
IsDropTargetPatternAvailable: false
IsExpandCollapsePatternAvailable: false
IsGridItemPatternAvailable: false
IsGridPatternAvailable: false
IsInvokePatternAvailable: false
IsItemContainerPatternAvailable: false
IsLegacyIAccessiblePatternAvailable: true
IsMultipleViewPatternAvailable: false
IsObjectModelPatternAvailable: false
IsRangeValuePatternAvailable: false
IsScrollItemPatternAvailable: false
IsScrollPatternAvailable: false
IsSelectionItemPatternAvailable: false
IsSelectionPatternAvailable: false
IsSpreadsheetItemPatternAvailable: false
IsSpreadsheetPatternAvailable: false
IsStylesPatternAvailable: false
IsSynchronizedInputPatternAvailable: true
IsTableItemPatternAvailable: false
IsTablePatternAvailable: false
IsTextChildPatternAvailable: false
IsTextEditPatternAvailable: false
IsTextPatternAvailable: false
IsTextPattern2Available: false
IsTogglePatternAvailable: false
IsTransformPatternAvailable: false
IsTransform2PatternAvailable: false
IsValuePatternAvailable: false
IsVirtualizedItemPatternAvailable: false
IsWindowPatternAvailable: false
IsCustomNavigationPatternAvailable: false
IsSelectionPattern2Available: false
FirstChild: [null]
LastChild: [null]
Next: "0 x 0" text
Previous: [null]
Other Props: Object has no additional properties
Children: Container has no children
Ancestors: "partattributerev" list item
"" list view
"Sample" window
"Desktop 1" pane
[ No Parent ]
由此,我需要获取 Next 或 Previous 属性值。