我正试图操纵Windows的计算器。如果我的程序找到一个实例(它确实如此),它需要向TestStack的White框架提供进程'startInfo以进行UIAutomation。但是,我一直得到以下例外:
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
来自以下代码行的found[0].StartInfo
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();
}
}
}
计算器进程已在运行。 (配件>计算器)