You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using the SetUp method in a very similar way to the example in README.md:
[SetUp]
public void SetUp()
{
if (Application.TryAttach(ExeFileName, out var app))
{
using (app)
{
app.MainWindow.FindButton("Reset").Invoke();
}
}
}
Basically, I've only removed the argument that I'm not using.
Locally, this works just fine, but on a build machine, I got an exception in TryAttach()
System.InvalidOperationException : Process was not started by this object, so requested information cannot be determined.
at System.Diagnostics.Process.get_StartInfo()
at Gu.Wpf.UiAutomation.Application.<>c__DisplayClass33_0.<TryAttach>b__0(Process x)
at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found)
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
at Gu.Wpf.UiAutomation.Application.TryAttach(ProcessStartInfo processStartInfo, OnDispose onDispose, Application& result)
at Gu.Wpf.UiAutomation.Application.TryAttach(String exeFileName, Application& result)
at *MyTestApp.MyTestClass*.Setup() in *MyTestClass file*
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
Accessing the StartInfo property is not allowed for all processes [depends on privileges] and should probably be wrapped in a try/catch in that case, if it fails, we can skip it because it's not a valid process to attach to anyway.
The text was updated successfully, but these errors were encountered:
jv42
added a commit
to jv42/Gu.Wpf.UiAutomation
that referenced
this issue
Mar 26, 2024
FixesGuOrg#184
Catch the exception in TryAttach so it behaves more like a "Try" method.
This code is only reached when the process we're looking for is not part of the Launched collection, so this change won't affect the main path of application re-use.
jv42
linked a pull request
Mar 26, 2024
that will
close
this issue
I'm using the SetUp method in a very similar way to the example in README.md:
Basically, I've only removed the argument that I'm not using.
Locally, this works just fine, but on a build machine, I got an exception in TryAttach()
It matches this line
Gu.Wpf.UiAutomation/Gu.Wpf.UiAutomation/Application.cs
Line 209 in d62e2e5
Accessing the
StartInfo
property is not allowed for all processes [depends on privileges] and should probably be wrapped in a try/catch in that case, if it fails, we can skip it because it's not a valid process to attach to anyway.The text was updated successfully, but these errors were encountered: