System.ComponentModel.Win32Exception:使用FlaUI + SpecFlow自动执行WPF应用程序时出现“访问被拒绝”错误

问题描述 投票:0回答:1

我遇到了一个不常发生的问题。我正在尝试使用UI testing自动执行FlaUI and SpecFlow。我正在尝试启动应用程序exeThe app runs for sometime and then throws the error.我收到以下错误。

System.ComponentModel.Win32Exception:'访问被拒绝'

public void Start()
        {
            try
            {
                _logger.Info("Synergy TestHub starting up in memory");

                _testHub = new SynergyTestHub(locator =>
                {
                    locator.RegisterFeatureService(Substitute.For<ISynergyLogger>());
                    locator.RegisterFeatureService(Substitute.For<ISynergyClientConfigService>());
                }, Config.SynergyEnvironment);


                // Run the Synergy Test Hub In Memory
                AsyncBlockingDeadlockAvoidanceHack.SafeWait(
                    async () => await _testHub.RunUiApplicationAsync(
                        _pathBuilder.ShipTrackerExePath,
                        600,
                        false));

                _controlAction.WaitFor(new TimeSpan(0, 0, 0, 50)); // Average time for ref data to load

                var process = Process.GetProcessesByName(Config.ShipTrackerFileName)[0];
                process.WaitForInputIdle();
                Application = Application.Attach(process.Id);
                ShipTrackerWindow = GetMainWindow();
            }
            catch (Exception exception)
            {
                _logger.Error($"Error Starting up Synergy TestHub in Memory. {exception.Message}");
                _logger.Warning("Killing processes that could be hanging around .. please try to run the test again");
                _processTerminator.KillProcess(new List<string>
                {
                    Config.ShipTrackerFileName, Config.SynergyHubAppName

                });

                throw;
            }
        }

StackTrace

堆栈跟踪:

ProcessManager.OpenProcess(Int32 processId, Int32 access, Boolean throwIfExited)
Process.GetProcessHandle(Int32 access, Boolean throwIfExited)
Process.WaitForInputIdle(Int32 milliseconds)
Process.WaitForInputIdle()
ApplicationDriver.Start() line 79
Hooks.BeforeScenario() line 133
lambda_method(Closure , IContextManager )
BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration) line 69
TestExecutionEngine.InvokeHook(IBindingInvoker invoker, IHookBinding hookBinding, HookType hookType) line 351
TestExecutionEngine.FireEvents(HookType hookType) line 340
TestExecutionEngine.FireScenarioEvents(HookType bindingEvent) line 321
TestExecutionEngine.OnScenarioStart() line 198
TestRunner.OnScenarioStart() line 54
RefreshTheViewsFeature.ScenarioStart()
RefreshTheViewsFeature.AutomationOfRefreshInManualPublishMode() line 34

process.WaitForInputIdle();抛出上述错误。

有帮助吗?

c# wpf process specflow flaui
1个回答
0
投票

您无权阅读设备中的所有过程,请尝试以管理员模式运行

© www.soinside.com 2019 - 2024. All rights reserved.