【问题标题】:Slow to get element with TestStack.White使用 TestStack.White 获取元素很慢
【发布时间】:2019-01-17 07:06:54
【问题描述】:

所以我正在做的是使用TestStack.White 中的.Exist<T> 方法来查看是否存在错误对话框。我遇到的问题是发现它非常慢。这是因为程序中有一个数据表,其中包含 400 多个项目,然后是这些项目的子项目。我不太确定如何才能更快地进行搜索,这是我试图查看是否存在的框:

Dialog Box

这里是关于它的信息:

"No Rates Returned":
How found: Selected from tree...
Name: "No rates returned."
ControlType: UIA_TextControlTypeId (0xC364)
LocalizedControlType: "text"
BoundingRectangle: {l:1635 t:462 r:1731 b:477}
IsEnabled: true
IsOffscreen: false
IsKeyboardFocusable: false
HasKeyboardFocus: false
AccessKey: ""
ProcessId: 3036
RuntimeId: [2A.6105AE]
AutomationId: "65535"
FrameworkId: "Win32"
ClassName: "Static"
NativeWindowHandle: 0x6105AE
ProviderDescription: "[pid:10424,providerId:0x6105AE Main:Nested [pid:3036,providerId:0x6105AE Annotation(parent link):Microsoft: Annotation Proxy (unmanaged:uiautomationcore.dll); Main:Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)]; Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]"
IsPassword: false
HelpText: ""
HeadingLevel: [Not supported]
LegacyIAccessible.ChildId: 0
LegacyIAccessible.DefaultAction: ""
LegacyIAccessible.Description: ""
LegacyIAccessible.Help: ""
LegacyIAccessible.KeyboardShortcut: ""
LegacyIAccessible.Name: "No rates returned."
LegacyIAccessible.Role: text (0x29)
LegacyIAccessible.State: read only (0x40)
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: false
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: [null]
Previous: "OK" button
Other Props: Object has no additional properties
Children: Container has no children
Ancestors: "" dialog
 "New Car  " window
 "Desktop 1" pane
 [ No Parent ]

对话框(本身):

How found: Selected from tree...
Name: ""
ControlType: UIA_WindowControlTypeId (0xC370)
LocalizedControlType: "dialog"
BoundingRectangle: {l:1621 t:413 r:1764 b:543}
IsEnabled: true
IsKeyboardFocusable: true
HasKeyboardFocus: false
ProcessId: 3036
RuntimeId: [2A.7109FC]
FrameworkId: "Win32"
ClassName: "#32770"
NativeWindowHandle: 0x7109FC
IsControlElement: true
IsContentElement: true
ProviderDescription: "[pid:10424,providerId:0x7109FC Main:Microsoft: Container Proxy (unmanaged:uiautomationcore.dll); Nonclient:Microsoft: Non-Client Proxy (unmanaged:uiautomationcore.dll); Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]"
HeadingLevel: [Not supported]
LegacyIAccessible.ChildId: 0
LegacyIAccessible.Role: dialog (0x12)
LegacyIAccessible.State: focusable (0x100000)
Transform.CanMove: true
Transform.CanResize: false
Transform.CanRotate: false
Window.CanMaximize: false
Window.CanMinimize: false
Window.IsModal: true
Window.IsTopmost: false
Window.WindowInteractionState: ReadyForUserInteraction (2)
Window.WindowVisualState: Normal (0)
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: false
IsTableItemPatternAvailable: false
IsTablePatternAvailable: false
IsTextChildPatternAvailable: false
IsTextEditPatternAvailable: false
IsTextPatternAvailable: false
IsTextPattern2Available: false
IsTogglePatternAvailable: false
IsTransformPatternAvailable: true
IsTransform2PatternAvailable: false
IsValuePatternAvailable: false
IsVirtualizedItemPatternAvailable: false
IsWindowPatternAvailable: true
IsCustomNavigationPatternAvailable: false
IsSelectionPattern2Available: false
FirstChild: "OK" button
LastChild: "No rates returned." text
Next: "Deductible" pane
Previous: [null]
Other Props: Object has no additional properties
Children: "OK" button
 "No rates returned." text
Ancestors: "New Car  " window
 "Desktop 1" pane
 [ No Parent ]

这是我用来拉取它的代码:

private bool GrabErrorOrExucute()
        {
            using (CoreAppXmlConfiguration.Instance.ApplyTemporarySetting(s => s.BusyTimeout = 500))
            {
                if (_mainWindow.Exists(SearchCriteria.ByAutomationId("65535")))
                {
                    var error = _mainWindow.Get(
                        SearchCriteria
                            .ByAutomationId(
                                "65535")); 
                    MessageBox.Show("Error has been thrown while getting rates, it will be displayed now...",
                        "Error While Getting Rates", MessageBoxButtons.OK, MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                    MessageBox.Show(error.Name, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error,
                        MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);


                    var okbtn = _mainWindow.Get<Button>(SearchCriteria.ByAutomationId("2"));
                    ratestat.Text = "Error While Getting Rate...";
                    Stop();
                    return true;
                }


                return false;
            }
        }

由于程序中的表格,这可能需要 10 到 15 分钟以上的时间。这是表格的样子(从 1 到 ~400)。我怎样才能让它更快?:

Window with table

【问题讨论】:

    标签: c# ui-automation white-framework teststack


    【解决方案1】:

    尝试使用: CoreAppXmlConfiguration.Instance.RawElementBasedSearch = true; 测试前的某个地方。 另一种选择是限制搜索深度: CoreAppXmlConfiguration.Instance.RawElementBasedSearch = true;

    对我来说,这两种方法与默认方法相比具有良好的性能

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-06
      • 2019-07-22
      • 2016-09-03
      • 1970-01-01
      • 2021-01-18
      • 1970-01-01
      • 2022-07-11
      • 2014-10-04
      相关资源
      最近更新 更多