2013-06-21 7 views
1

По какой-то причине я получаю ошибку времени выполнения от White.Core при попытке найти дочерний элемент Window из своего родителя.Автоматизация пользовательского интерфейса с белой проблемой поиска детей

ERROR отображается:

White.Core.Mappings.ControlDictionaryException: Could not find TestControl for ControlType=window and FrameworkId:Win32 
at White.Core.Mappings.ControlDictionary.GetTestControlType(ControlType controlType, String frameWorkId, Boolean isNativeControl) 
at White.Core.Mappings.ControlDictionary.GetTestType(String className, ControlType controlType, String frameworkId, String name, Boolean isNativeControl) 
at White.Core.Mappings.ControlDictionary.GetTestType(AutomationElement automationElement) 
at White.Core.Factory.DictionaryMappedItemFactory.Create(AutomationElement automationElement, ActionListener actionListener) 
at White.Core.Factory.DictionaryMappedItemFactory.Create(AutomationElement automationElement, ActionListener actionListener, Type customItemType) 
at White.Core.Factory.PrimaryUIItemFactory.Create(SearchCriteria searchCriteria, ActionListener actionListener) 
at White.Core.UIItems.Container.NonCachedContainerItemFactory.Find(SearchCriteria searchCriteria) 
at White.Core.UIItems.Container.ContainerItemFactory.Get(SearchCriteria searchCriteria, ActionListener uiItemActionListener) 
at White.Core.Sessions.NullWindowSession.Get(ContainerItemFactory containerItemFactory, SearchCriteria searchCriteria, ActionListener actionListener) 
at White.Core.UIItems.Container.CurrentContainerItemFactory.Find(SearchCriteria searchCriteria, WindowSession windowSession) 
at White.Core.UIItems.UIItemContainer.Get(SearchCriteria searchCriteria) 
--- End of inner exception stack trace --- 
at White.Core.UIItems.UIItemContainer.Get(SearchCriteria searchCriteria) 
at ICOWrapper.Form1.wasUserLoggedIn(String id1, String id2) 
at ICOWrapper.Form1.button2_Click(Object sender, EventArgs e) 
at System.Windows.Forms.Control.OnClick(EventArgs e) 
at System.Windows.Forms.Button.OnClick(EventArgs e) 
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) 
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) 
at System.Windows.Forms.Control.WndProc(Message& m) 
at System.Windows.Forms.ButtonBase.WndProc(Message& m) 
at System.Windows.Forms.Button.WndProc(Message& m) 
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 

Текущая структура, я пытаюсь ориентироваться заключается в следующем:

Главная Window-> Panel-> Окно

и я использую в C#

 public Boolean wasUserLoggedIn(string id1, string id2) 
    { 
     Thread.Sleep(500); 
     var mdiClient = window.MdiChild(SearchCriteria.ByControlType(ControlType.Pane).AndAutomationId(id1)); 
     Thread.Sleep(500); 
     var selectPatient = (Window)mdiClient.Get(SearchCriteria.ByControlType(ControlType.Window).AndAutomationId(id2)); 
     Thread.Sleep(500); 
     return selectPatient != null? true: false; 
    } 

и вызова метода следующим образом:

Boolean wasFound = wasUserLoggedIn("40960", "40961"); 

UIspy объектов, используемых для идентификации ControlType и AutomationID:

AutomationId: 40960 
ControlType: ControlType.Pane 
Name: 
HelpText: 
Bounding rectangle: 8,78,900,581 
ClassName: MDIClient 
IsOffScreen: False 
FrameworkId: Win32 
ProcessId: 5964 


AutomationId: 40961 
ControlType: ControlType.Window 
Name: Home 
HelpText: 
Bounding rectangle: 8,59,900,600 
ClassName: ClaWin01000000H_2 
IsOffScreen: False 
FrameworkId: Win32 
ProcessId: 5964 

ответ

1

Я рекомендую обновить до TestStack.White, а не в старой Белой библиотеке.

Проблема в том, что вы не должны использовать .Get() для разрешения Windows. Для приложений MDI вы должны использовать MdiChild(), если это окно modal, используйте .ModalWindow() на окне parent или вернитесь в приложение, затем используйте Window(), чтобы получить окно.

Надеюсь, что поможет

0

ли Pane потомок WindowAutomationElement? Window, который вы пытаетесь найти, может оказаться не в фокусе.