We have been using Telerik Testing Framework for our WPF project. It is working fine with the previous version 2012.2.1420.0.
But today when I upgraded with the latest version 2013.1.806.0, it throws "System.TypeInitializationException" when it is trying find control using automationId (this.WpfWindow.Find.ByAutomationId<T>("automationId"))
Details of the exception thrown are as follows
Exception thrown during the wait for a condition. Error: Unexpected error while waiting on condition. Error: System.TypeInitializationException: The type initializer for 'ArtOfTest.WebAii.Silverlight.ObjectSerializer' threw an exception. ---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at ArtOfTest.WebAii.Silverlight.ObjectSerializer.InitKnownTypes()
at ArtOfTest.WebAii.Silverlight.ObjectSerializer..cctor()
--- End of inner exception stack trace ---
at ArtOfTest.WebAii.Silverlight.ObjectSerializer.Serialize(Type t, Object o)
at ArtOfTest.WebAii.Silverlight.SilverlightCommand.AsString()
at ArtOfTest.WebAii.Wpf.WpfProxy.CreateCommand(SilverlightCommand SlCommand)
at ArtOfTest.WebAii.Wpf.WpfProxy.ExecuteSLCommand(SilverlightCommand cmd)
at ArtOfTest.WebAii.Wpf.WpfProxy.GetAllVisualTrees()
at ArtOfTest.WebAii.Wpf.WpfWindow.RefreshVisualTrees()
at ArtOfTest.WebAii.Silverlight.VisualFind.RefreshRoot()
at ArtOfTest.WebAii.Silverlight.VisualWait.WaitForExistsByFindInfo(VisualFindInfo findInfo)
at ArtOfTest.Common.WaitAsync._worker_DoWork[T,V](Object waitParam)
We have been referring three DLLs in our Project
1. ArtOfTest.WebAii.dll
2. Telerik.WebAii.Controls.Xaml.dll
3. Telerik.WebAii.Controls.Xaml.Wpf.dll
Do we need to refer any additional binaries?
Thanks & Regards,
Raj
15 Answers, 1 is accepted
So I have taken down our application to its bare bones and created a simple test project. See attached zip file with project.
The project is purely getting the application running with no interaction with it yet but even though Raj posted an example of when we were attempting to find a control you will see from my example that purely calling Manager.ActiveApplication.MainWindow.RefreshVisualTrees(); causes the same error
To get it running:
- 1. Replace the exePath With any Wpf Application
- 2. replace windowsProcessNameOfExe with the process name of your Wpf Application (to help close down duplicate applications).
The Test output for me from executing the test is:
Debug Trace:
************************
ReflectionTypeLoadException - Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Could not load file or assembly 'Telerik.TestStudio.Interfaces, Version=2013.1.806.0, Culture=neutral, PublicKeyToken=b9f4c4e36181b3de' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Telerik.TestStudio.Interfaces, Version=2013.1.806.0, Culture=neutral, PublicKeyToken=b9f4c4e36181b3de' or one of its dependencies. The system cannot find the file specified.
************************
Test method TelerikIssuePOC.UnitTest1.TestMethod1 threw exception:
System.TypeInitializationException: The type initializer for 'ArtOfTest.WebAii.Silverlight.ObjectSerializer' threw an exception. ---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at ArtOfTest.WebAii.Silverlight.ObjectSerializer.InitKnownTypes()
at ArtOfTest.WebAii.Silverlight.ObjectSerializer..cctor()
--- End of inner exception stack trace ---
at ArtOfTest.WebAii.Silverlight.ObjectSerializer.Serialize(Type t, Object o)
at ArtOfTest.WebAii.Silverlight.SilverlightCommand.AsString()
at ArtOfTest.WebAii.Wpf.WpfProxy.CreateCommand(SilverlightCommand SlCommand)
at ArtOfTest.WebAii.Wpf.WpfProxy.ExecuteSLCommand(SilverlightCommand cmd)
at ArtOfTest.WebAii.Wpf.WpfProxy.GetAllVisualTrees()
at ArtOfTest.WebAii.Wpf.WpfWindow.RefreshVisualTrees()
at TelerikIssuePOC.UnitTest1.Start(String exePath, String logPath) in UnitTest1.cs: line 79
at TelerikIssuePOC.UnitTest1.TestMethod1() in UnitTest1.cs: line 21
Here is the test code class from the attached project
using
ArtOfTest.WebAii.Core;
using
ArtOfTest.WebAii.Wpf;
using
Microsoft.VisualStudio.TestTools.UnitTesting;
using
System;
using
System.Diagnostics;
using
System.Linq;
using
System.Reflection;
using
System.Threading;
namespace
TelerikIssuePOC
{
[TestClass]
public
class
UnitTest1
{
private
string
exePath = @
"C:\Temp\TestSortedView\TestSortedView.exe"
;
private
static
string
windowsProcessNameOfExe =
"TestSortedView"
;
private
string
logPath = @
"C:\Temp\TelerikTestlog"
;
[TestMethod]
public
void
TestMethod1()
{
Start(exePath, logPath);
}
/// <summary>
/// Gets the application.
/// </summary>
private
static
WpfApplication Application {
get
;
set
; }
/// <summary>
/// Gets the manager.
/// </summary>
private
static
Manager Manager {
get
;
set
; }
/// <summary>
/// Starts the test runner.
/// </summary>
public
static
void
Start(
string
exePath,
string
logPath)
{
if
(Manager ==
null
)
{
StartUpManager(exePath, logPath);
}
try
{
// This is in case you have the application running when you start the test
KillAllTestAppProcesses(windowsProcessNameOfExe);
// Launch Application
Application = Manager.LaunchNewApplication(Manager.Settings.Wpf.DefaultApplicationPath);
}
// sem to be getting a ReflectionType Load Exception
// LoaderExpection = "Could not load file or assembly 'Telerik.TestStudio.Interfaces, Version=2013.1.806.0, Culture=neutral, PublicKeyToken=b9f4c4e36181b3de' or one of its dependencies. The system cannot find the file specified.":"Telerik.TestStudio.Interfaces, Version=2013.1.806.0, Culture=neutral, PublicKeyToken=b9f4c4e36181b3de"
// NB: This does not exist in Framework installation.
catch
(ReflectionTypeLoadException rtle)
{
Trace.WriteLine(
"************************"
);
Trace.WriteLine(
"ReflectionTypeLoadException - "
+ rtle.Message);
foreach
(var le
in
rtle.LoaderExceptions)
{
Trace.WriteLine(le.Message);
}
Trace.WriteLine(
"************************"
);
// This is because even though the above throws an error the application still opens
KillAllTestAppProcesses(windowsProcessNameOfExe);
// NB: This time the exception above is not thrown when Application Launch is initiated
Application = Manager.LaunchNewApplication(Manager.Settings.Wpf.DefaultApplicationPath);
}
Manager.ActiveApplication.WaitForWindow(
"MainWindow"
);
//This line causes exactly the same error as when we start to Find controls
try
{
Manager.ActiveApplication.MainWindow.RefreshVisualTrees();
}
catch
(TypeInitializationException ex)
{
throw
;
}
}
/// <summary>
/// The start up manager.
/// </summary>
/// <param name="exePath">
/// The exe path.
/// </param>
/// <param name="logPath">
/// The log path.
/// </param>
private
static
void
StartUpManager(
string
exePath,
string
logPath)
{
var settings =
new
Settings
{
ExecuteCommandTimeout = 30000,
ExecutionDelay = 500,
UnexpectedDialogAction = UnexpectedDialogAction.HandleAndFailTest,
CreateLogFile =
true
,
LogLocation = logPath,
QueryEventLogErrorsOnExit =
true
,
LogAnnotations =
true
,
Wpf =
new
Settings.WpfSettings
{
DefaultApplicationPath = exePath,
},
SimulatedMouseMoveSpeed = 1.0f
};
Manager =
new
Manager(settings);
Manager.Start();
}
/// <summary>
/// The kill all current exe processes.
/// </summary>
public
static
void
KillAllTestAppProcesses(
string
processName)
{
var processes = Process.GetProcesses().Where(p => p.ProcessName == processName);
if
(processes.Any())
{
foreach
(var atlasProcess
in
processes)
{
if
(!atlasProcess.WaitForExit(5000))
{
atlasProcess.Kill();
}
}
}
// Give it a second for processes to be killed
Thread.Sleep(1000);
}
}
}
Seems that a dependency to test studio creeped in?
Telerik, could you please advise?
Thank you for contacting us.
Unfortunately I was no able to reproduce this issue on our end. Please send us a sample application with a test project so we can reproduce it in our development environment and give you a proper solution.
Thank you fro your understanding.
Boyan Boev
Telerik
Test Studio Trainings
Can any other posters to this thread try my project and reproduce it with your application? all you should have to change is the application path, the Process name it runs as and a log path (even though its not being output).
private
string
exePath = @
"C:\Temp\TestSortedView\TestSortedView.exe"
;
private
static
string
windowsProcessNameOfExe =
"TestSortedView"
;
private
string
logPath = @
"C:\Temp\TelerikTestlog"
;
The former is used in ArtOfTest.WebAii by ArtOfTest.WebAii.Messaging.Http.WcfHttpRawRequest(Factory), the latter is used by ArtOfTest.WebAii.Messaging.Http.WcfHttpRawRequestFactory.
Hope this helps.
Thank you for providing the test and the application. I was able to reproduce this issue and I can confirm that this is a bug. In the new release of our framework we did not install and add in the GAC Telerik.TestStudio.Interfaces.dll.
I have logged a bug report on this issue which you can track here.
I've updated your account with Telerik points.
We really appreciate when you find bugs and take the time to report them.
Boyan Boev
Telerik
Test Studio Trainings
Best regards
I am attaching Telerik.TestStudio.Interfaces.dll to this ticket.
Please copy it to the bin folder of the framework and install it into the GAC. Here is an article which describes how you can do this.
If you have Visual Studio installed on your computer: On the taskbar, click Start, click All Programs, click Visual Studio, click Visual Studio Tools, and then click Visual Studio Command Prompt and type gacutil /i path to the dll.
Hope this helps.
Regards,
Boyan Boev
Telerik
Test Studio Trainings
Glad to hear that!
If you need additional assistance, please do not hesitate to contact us.
Boyan Boev
Telerik
Test Studio Trainings