I'm having an issue running automated tests driving a silverlight app. I've gone through all the browser configuration and checked I can run sample tests without an issue, so it's likely to be something wrong in my code.
The Manager settings are initialised as:
var settings = new Settings { EnableSilverlight = true, ExecutionDelay = 50, EnableUILessRequestViewing = false, QueryEventLogErrorsOnExit = false, EnableScriptLogging = false, AnnotateExecution = true, AnnotationMode = AnnotationMode.All, RecycleBrowser = true, DefaultBrowser = BrowserType.InternetExplorer, };
The browser is connecting via https with navigation and automation on htmlinput elements working OK, but whenever it tries to connect to the silverlight app I get the stack trace below - tested on two seperate machines (one server 2003 x86, one windows 7 x64):
ArtOfTest.WebAii.Exceptions.ExecuteCommandException : ExecuteCommand failed!
InError set by the client. Client Error:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x000003E9): System.TypeInitializationException: The type initializer for 'ArtOfTest.WebAii.Silverlight.ObjectSerializer' threw an exception. ---> System.InvalidOperationException: Method may only be called on a Type for which Type.IsGenericParameter is true.
at System.RuntimeType.get_GenericParameterPosition()
--- End of inner exception stack trace ---
at System.Windows.Browser.ManagedObjectInfo.Invoke(ManagedObject obj, InvokeType invokeType, String memberName, ScriptParam[] args)
at System.Windows.Hosting.ManagedHost.InvokeScriptableMember(IntPtr pHandle, Int32 nMemberID, Int32 nInvokeType, Int32 nArgCount, ScriptParam[] pArgs, ScriptParam& pResult, ExceptionInfo& pExcepInfo)
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
at ArtOfTest.InternetExplorer.JsObjectWrapper.Call(String methodName, Object[] args)
at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessSilverlightCommand(BrowserCommand request)
at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessCommand(WebBrowserClass ieInstance, BrowserCommand request, IHTMLDocument2 document)
BrowserCommand (Type:'Silverlight',Info:'NotSet',Action:'NotSet',Target:'ElementId (tagName: 'object',occurrenceIndex: '0')',Data:'{"Method":null,"Property":null,"Reference":null,"Reference2":null,"Type":10,"Value":"FrameworkElement;CheckBox;ChildWindow;ComboBox;DataGridCell;DataGridRow;DataGrid;RadioButton;RepeatButton;DataGridCellsPresenter;DataGridColumnHeader;DataGridColumnHeadersPresenter;DataGridDetailsPresenter;DataGridFrozenGrid;DataGridRowHeader;DataGridRowsPresenter;Calendar;CalendarButton;CalendarDayButton;CalendarItem;DatePicker;DatePickerTextBox;GridSplitter;PreviewControl;TabControl;TabItem;TabPanel;Shape;Path;Ellipse;Line;Polygon;Polyline;Rectangle;Glyphs;Panel;Image;Canvas;TextBlock;MediaElement;InkPresenter;MultiScaleImage;StackPanel;Control;TextBox;PasswordBox;Grid;ItemsControl;Border;ContentControl;ContentPresenter;ItemsPresenter;Popup;UserControl;ButtonBase;Button;ToggleButton;Selector;HyperlinkButton;ListBox;RangeBase;ScrollBar;Thumb;ScrollContentPresenter;ScrollViewer;Slider;ToolTip;ProgressBar;ListBoxItem;ComboBoxItem;VirtualizingStackPanel;"}',ClientId:'Client_d284ca17-4bc1-4219-a0e9-56a2af98f06b',HasFrames:'False',FramesInfo:'',TargetFrameIndex:'-1',InError:'True',Response:'System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x000003E9): System.TypeInitializationException: The type initializer for 'ArtOfTest.WebAii.Silverlight.ObjectSerializer' threw an exception. ---> System.InvalidOperationException: Method may only be called on a Type for which Type.IsGenericParameter is true.
at System.RuntimeType.get_GenericParameterPosition()
--- End of inner exception stack trace ---
at System.Windows.Browser.ManagedObjectInfo.Invoke(ManagedObject obj, InvokeType invokeType, String memberName, ScriptParam[] args)
at System.Windows.Hosting.ManagedHost.InvokeScriptableMember(IntPtr pHandle, Int32 nMemberID, Int32 nInvokeType, Int32 nArgCount, ScriptParam[] pArgs, ScriptParam& pResult, ExceptionInfo& pExcepInfo)
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
at ArtOfTest.InternetExplorer.JsObjectWrapper.Call(String methodName, Object[] args)
at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessSilverlightCommand(BrowserCommand request)
at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessCommand(WebBrowserClass ieInstance, BrowserCommand request, IHTMLDocument2 document)')
InnerException: none.
at ArtOfTest.WebAii.Core.Browser.ExecuteCommandInternal(BrowserCommand request)
at ArtOfTest.WebAii.Core.Browser.ExecuteCommand(BrowserCommand request, Boolean performDomRefresh, Boolean waitUntilReady)
at ArtOfTest.WebAii.Silverlight.SilverlightProxy.ExecuteSLCommand(SilverlightCommand cmd)
at ArtOfTest.WebAii.Silverlight.SilverlightProxy.PublishKnownControlTypes(List`1 knownTypes)
at ArtOfTest.WebAii.Silverlight.SilverlightApp.Connect(Int32 timeout)
at ArtOfTest.WebAii.Silverlight.SilverlightApp.Connect()
at ArtOfTest.WebAii.Silverlight.SilverlightAppsList.get_Item(Int32 index)
Helpers\TestHelper.cs(15,0): at Insurer.Analytics.Acceptance.Test.Helpers.TestHelper.get_SilverlightApp()