Silverlight 2.0 Textbox and Combobox Controls

Aug 28, 2009 at 10:28 PM
Edited Aug 29, 2009 at 4:32 AM

I'm new to both White and Silverlight, and so far White looks so much better than everyother Silverlight tool/framework out there, great job with it.  I have been tasked with creating an automation framework on top of White for Silverlight and I'm running into a couple of issues.  Based on what I have been reading I think it is something I'm donig, but I can't figure out what.  Any help will be greatly appriciated.

Issue 1.  I can't get it to work with TextBoxes.  Based on the inner exceptions below (and UISpy) it looks like the controls are setup as one thing in Silverlight and displayed as another, I don't understand how to fix this.

Here is the code from the Silverlight application: '<TextBox TextChanged="TextBox_TextChanged" AutomationProperties.AutomationId="TextBoxOne"/>' and when I run the following I get an exception (See textbox exception below).

InternetExplorerWindow

 

browserWindow = InternetExplorer.Launch(@"C:\TestPage.html", "SampleUI - Windows Internet Explorer");

White.WebBrowser.Silverlight.

SilverlightDocument document = browserWindow.SilverlightDocument;

Core.UIItems.

TextBox txt = document.Get<Core.UIItems.TextBox>("TextBoxOne");

 

Issue 2. I can't get it to work with combo boxes.  Here is the code from the Silverlight application: <ComboBox SelectionChanged="ComboBox_SelectionChanged" AutomationProperties.AutomationId="ComboBoxOne" > <ComboBoxItem Content="Item 1" AutomationProperties.AutomationId="ComboBoxOneItem1"/> <ComboBoxItem Content="Item 2" AutomationProperties.AutomationId="ComboBoxOneItem2"/> <ComboBoxItem Content="Item 3" AutomationProperties.AutomationId="ComboBoxOneItem3"/> <ComboBoxItem Content="Item 4" AutomationProperties.AutomationId="ComboBoxOneItem4"/> <ComboBoxItem Content="Item 5" AutomationProperties.AutomationId="ComboBoxOneItem5"/> </ComboBoxand when I run the following I get an exception (see ComboBox exception below).

InternetExplorerWindow

 

browserWindow = InternetExplorer.Launch(@"C:\TestPage.html", "SampleUI - Windows Internet Explorer");

White.WebBrowser.Silverlight.

SilverlightDocument document = browserWindow.SilverlightDocument;

Core.UIItems.ListBoxItems.

ComboBox cmb = document.Get<Core.UIItems.ListBoxItems.ComboBox>("ComboBoxOne");

TextBoxException:

Inner exception: {"Could not find TestControl for ControlType=edit and FrameworkId:Silverlight"}

Core.WhiteException was unhandled
  Source="White.Core"
  StackTrace:
       at Core.UIItems.UIItemContainer.Get(SearchCriteria searchCriteria) in d:\white\Core\UIItems\UIItemContainer.cs:line 92
       at Core.UIItems.UIItemContainer.Get[T](SearchCriteria searchCriteria) in d:\white\Core\UIItems\UIItemContainer.cs:line 73
       at Core.UIItems.UIItemContainer.Get[T](String primaryIdentification) in d:\white\Core\UIItems\UIItemContainer.cs:line 60
       at Playing_With_White_Project.Form1.button1_Click(Object sender, EventArgs e) in C:\Playing_With_White_Project\Form1.cs:line 46
       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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at Playing_With_White_Project.Program.Main() in C:\Playing_With_White_Project\Program.cs:line 20
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: Core.Mappings.ControlDictionaryException
       Message="Could not find TestControl for ControlType=edit and FrameworkId:Silverlight"
       Source="White.Core"
       StackTrace:
            at Core.Mappings.ControlDictionary.GetTestControlType(ControlType controlType, String frameWorkId, Boolean isNativeControl) in d:\white\Core\Mappings\ControlDictionary.cs:line 137
            at Core.Mappings.ControlDictionary.GetTestType(String className, ControlType controlType, String frameworkId, String name, Boolean isNativeControl) in d:\white\Core\Mappings\ControlDictionary.cs:line 204
            at Core.Mappings.ControlDictionary.GetTestType(AutomationElement automationElement) in d:\white\Core\Mappings\ControlDictionary.cs:line 196
            at Core.Factory.DictionaryMappedItemFactory.Create(AutomationElement automationElement, ActionListener actionListener) in d:\white\Core\Factory\DictionaryMappedItemFactory.cs:line 15
            at Core.Factory.DictionaryMappedItemFactory.Create(AutomationElement automationElement, ActionListener actionListener, Type customItemType) in d:\white\Core\Factory\DictionaryMappedItemFactory.cs:line 22
            at Core.Factory.PrimaryUIItemFactory.Create(SearchCriteria searchCriteria, ActionListener actionListener) in d:\white\Core\Factory\PrimaryUIItemFactory.cs:line 96
            at Core.UIItems.Container.NonCachedContainerItemFactory.Find(SearchCriteria searchCriteria) in d:\white\Core\UIItems\Container\NonCachedContainerItemFactory.cs:line 25
            at Core.UIItems.Container.ContainerItemFactory.Get(SearchCriteria searchCriteria, ActionListener uiItemActionListener) in d:\white\Core\UIItems\Container\ContainerItemFactory.cs:line 14
            at Core.Sessions.NullWindowSession.Get(ContainerItemFactory containerItemFactory, SearchCriteria searchCriteria, ActionListener actionListener) in d:\white\Core\Sessions\NullWindowSession.cs:line 19
            at Core.UIItems.Container.CurrentContainerItemFactory.Find(SearchCriteria searchCriteria, WindowSession windowSession) in d:\white\Core\UIItems\Container\CurrentContainerItemFactory.cs:line 41
            at Core.UIItems.UIItemContainer.Get(SearchCriteria searchCriteria) in d:\white\Core\UIItems\UIItemContainer.cs:line 85
       InnerException:

ComboBox Exception:

Inner Exception: {"Could not find TestControl for ControlType=combo box and FrameworkId:Silverlight"}

Core.WhiteException was unhandled
  Source="White.Core"
  StackTrace:
       at Core.UIItems.UIItemContainer.Get(SearchCriteria searchCriteria) in d:\white\Core\UIItems\UIItemContainer.cs:line 92
       at Core.UIItems.UIItemContainer.Get[T](SearchCriteria searchCriteria) in d:\white\Core\UIItems\UIItemContainer.cs:line 73
       at Core.UIItems.UIItemContainer.Get[T](String primaryIdentification) in d:\white\Core\UIItems\UIItemContainer.cs:line 60
       at Playing_With_White_Project.Form1.button1_Click(Object sender, EventArgs e) in C:\Playing_With_White_Project\Form1.cs:line 48
       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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at Playing_With_White_Project.Program.Main() in C:\Playing_With_White_Project\Program.cs:line 20
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: Core.Mappings.ControlDictionaryException
       Message="Could not find TestControl for ControlType=combo box and FrameworkId:Silverlight"
       Source="White.Core"
       StackTrace:
            at Core.Mappings.ControlDictionary.GetTestControlType(ControlType controlType, String frameWorkId, Boolean isNativeControl) in d:\white\Core\Mappings\ControlDictionary.cs:line 137
            at Core.Mappings.ControlDictionary.GetTestType(String className, ControlType controlType, String frameworkId, String name, Boolean isNativeControl) in d:\white\Core\Mappings\ControlDictionary.cs:line 204
            at Core.Mappings.ControlDictionary.GetTestType(AutomationElement automationElement) in d:\white\Core\Mappings\ControlDictionary.cs:line 196
            at Core.Factory.DictionaryMappedItemFactory.Create(AutomationElement automationElement, ActionListener actionListener) in d:\white\Core\Factory\DictionaryMappedItemFactory.cs:line 15
            at Core.Factory.DictionaryMappedItemFactory.Create(AutomationElement automationElement, ActionListener actionListener, Type customItemType) in d:\white\Core\Factory\DictionaryMappedItemFactory.cs:line 22
            at Core.Factory.PrimaryUIItemFactory.Create(SearchCriteria searchCriteria, ActionListener actionListener) in d:\white\Core\Factory\PrimaryUIItemFactory.cs:line 96
            at Core.UIItems.Container.NonCachedContainerItemFactory.Find(SearchCriteria searchCriteria) in d:\white\Core\UIItems\Container\NonCachedContainerItemFactory.cs:line 25
            at Core.UIItems.Container.ContainerItemFactory.Get(SearchCriteria searchCriteria, ActionListener uiItemActionListener) in d:\white\Core\UIItems\Container\ContainerItemFactory.cs:line 14
            at Core.Sessions.NullWindowSession.Get(ContainerItemFactory containerItemFactory, SearchCriteria searchCriteria, ActionListener actionListener) in d:\white\Core\Sessions\NullWindowSession.cs:line 19
            at Core.UIItems.Container.CurrentContainerItemFactory.Find(SearchCriteria searchCriteria, WindowSession windowSession) in d:\white\Core\UIItems\Container\CurrentContainerItemFactory.cs:line 41
            at Core.UIItems.UIItemContainer.Get(SearchCriteria searchCriteria) in d:\white\Core\UIItems\UIItemContainer.cs:line 85
       InnerException:

Thanks,

Geremy

Aug 31, 2009 at 9:54 PM

I found my own answers :).

For the textbox problem the solution came from: http://www.codeplex.com/white/WorkItem/View.aspx?WorkItemId=2305

For the combobox problem I grapped the latest code with change set: 31228.

I also ran into an issue with listboxes, for this I used the same solution for the textbox, but with the line: items.Add(ControlDictionaryItem.Primary(typeof(Win32ListItem), ControlType.ListItem)); and it worked just fine.

 

Thanks White is great.