I am trying to manipulate Windows' Calculator. If my program finds an instance (which it does), it needs to provide the process' startInfo to TestStack's White framework for UIAutomation. However, I keep getting the following exception:
System.ArgumentException was unhandled
HResult=-0
Message=The path is not of a legal form.
Source=mscorlib
StackTrace:
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.GetFullPathInternal(String path)
at System.IO.FileInfo.Init(String fileName, Boolean checkHost)
at System.IO.FileInfo..ctor(String fileName)
at TestStack.White.Application.Launch(ProcessStartInfo processStartInfo) in c:\TeamCity\buildAgent\work\89a20b30302799e\src\TestStack.White\Application.cs:line 60
at TestStack.White.Application.AttachOrLaunch(ProcessStartInfo processStartInfo) in c:\TeamCity\buildAgent\work\89a20b30302799e\src\TestStack.White\Application.cs:line 144
at Test_with_GUI.Tests.UIAutomation.Test() in c:\Users\BLAH\Test with GUI\test with gui\Tests\UIAutomation.cs:line 24
at Test_with_GUI.MainWindow.testing_component7() in c:\Users\BLAH\Test with GUI\test with gui\MainWindow.xaml.cs:line 257
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException
at found[0].StartInfo
from the following lines of code
Process[] found = Process.GetProcessesByName("calc");
if (found.Length > 0)
{
using (var app = TestStack.White.Application.AttachOrLaunch(found[0].StartInfo))
{
using (var win = app.GetWindow(SearchCriteria.ByText("Calculator"), InitializeOption.NoCache))
{
Manipulation();
}
}
}
The Calculator Process is already running. (Accessories > Calculator)