Модальное окно, возвращающее ноль - PullRequest
2 голосов
/ 12 июня 2019

Я пытаюсь автоматизировать процесс, используя teststack.white У меня главное окно в виде mainwindow Я пытаюсь получить дочернее окно, используя следующий код.

 var modalWindows = mainwindow.ModalWindows();

            modalWindow = modalWindows.Where(x => x.Name == "Terminal Pattern").FirstOrDefault();

Но он возвращает NULL

Информация о дочернем окне из inspect.exe

How found:  Selected from tree...
Name:   "Terminal Pattern"
ControlType:    UIA_WindowControlTypeId (0xC370)
LocalizedControlType:   "window"
BoundingRectangle:  {l:617 t:160 r:1303 b:880}
IsEnabled:  true
IsOffscreen:    false
IsKeyboardFocusable:    true
HasKeyboardFocus:   false
AcceleratorKey: ""
AccessKey:  ""
ProcessId:  32716
RuntimeId:  [2A.6B1C2A]
AutomationId:   ""
FrameworkId:    "WPF"
ClassName:  "Window"
NativeWindowHandle: 0x6B1C2A
IsControlElement:   true
IsContentElement:   true
ProviderDescription:    "[pid:29772,providerId:0x6B1C2A Main:Nested [pid:32716,providerId:0x6B1C2A Main(parent link):Unidentified Provider (managed:MS.Internal.Automation.ElementProxy, PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)]; Nonclient:Microsoft: Non-Client Proxy (unmanaged:uiautomationcore.dll); Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:uiautomationcore.dll)]"
IsPassword: false
ItemStatus: ""
ItemType:   ""
IsRequiredForForm:  false
HelpText:   ""
ClickablePoint: {x:968 y:551}
Orientation:    0
IsDialog:   [Not supported]
LegacyIAccessible.ChildId:  0
LegacyIAccessible.DefaultAction:    ""
LegacyIAccessible.Description:  ""
LegacyIAccessible.Help: ""
LegacyIAccessible.KeyboardShortcut: ""
LegacyIAccessible.Name: "Terminal Pattern"
LegacyIAccessible.Role: window (0x9)
LegacyIAccessible.State:    focusable (0x100000)
LegacyIAccessible.Value:    ""
Transform.CanMove:  true
Transform.CanResize:    true
Transform.CanRotate:    false
Window.CanMaximize: true
Window.CanMinimize: true
Window.IsModal: false
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:    true
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: (null) title bar
LastChild:  "Cancel" button
Next:   "c# - How to get window using TestStack.White - Stack Overflow - Google Chrome" pane
Previous:   "Microsoft Visual Studio" window
Other Props:    Object has no additional properties
Children:   (null) title bar
    "Pattern" group
    "" check box
    "Field cables terminate on right" text
    "Preview" group
    "i" text
    "To set the terminal class, select a terminal type before creating the pattern.
Once the pattern is created, the type of indivi
    "OK" button
    "Cancel" button
Ancestors:  "Desktop 1" pane
    [ No Parent ]

Я новичок в C # и автоматизации и не могу найти какую-либо полезную информацию из документации по teststack.white

1 Ответ

0 голосов
/ 12 июня 2019

Я перепроверил проблему, и ответ не использовать .Where().

Вместо этого вы можете использовать .Single() ( Но только если есть только один элемент ).

Если это не так, вы можете использовать .FirstOrDefault().Name, это будет ваш первый элемент, как то, что вы пытаетесь сделать сейчас.

...