AutoSetUpConfiguredDrivers 偶尔会抛出“索引超出范围”异常

AutoSetUpConfiguredDrivers occasionally throws an 'Index out of range" Exception

这是我的 GlobalSetup 的内容 - 偶尔当我 运行 时,对 AutoSetUpConfiguredDrivers 的调用会抛出异常:

System.ArgumentOutOfRangeException: '索引超出范围。必须为非负数且小于集合的大小。 (参数'index')'

        EdgeOptions Options = new EdgeOptions();
            Options.AddArgument("window-size=1600,900");
            Options.AcceptInsecureCertificates = true;

        EdgeOptions HeadlessOptions = new EdgeOptions();
            HeadlessOptions.AddArgument("headless");
            HeadlessOptions.AddArgument("window-size=1600,900");
            HeadlessOptions.AcceptInsecureCertificates = true;

        AtataContext.GlobalConfiguration
            .UseChrome().WithArguments("ignore-certificate-errors", "window-size=1600,900")
            .UseChrome().WithArguments("ignore-certificate-errors", "window-size=1600,900", "headless").WithAlias("chrome-headless")
            .UseFirefox().WithGlobalCapability("acceptInsecureCerts", true).WithArguments("--width=1600").WithArguments("--height=900")
            .UseFirefox().WithGlobalCapability("acceptInsecureCerts", true).WithArguments("--width=1600").WithArguments("--height=900").WithArguments("--headless").WithAlias("firefox-headless")
            .UseEdge().WithOptions(Options)
            .UseEdge().WithOptions(HeadlessOptions).WithAlias("edge-headless")
            .UseCulture("en-US")
            .AddScreenshotFileSaving()
            .UseNUnitTestName()
            .UseNUnitTestSuiteName()
            .UseNUnitTestSuiteType()
            .UseNUnitAssertionExceptionType()
            .UseNUnitAggregateAssertionStrategy()
            .UseNUnitWarningReportStrategy()
            .AddNUnitTestContextLogging()
                .WithMinLevel(LogLevel.Info)
                .WithoutSectionFinish()
            .LogNUnitError()
            .TakeScreenshotOnNUnitError("Test Failure")
            .OnCleanUpAddArtifactsToNUnitTestContext();            

        //DriverSetup.AutoSetUp(BrowserNames.Edge);
        AtataContext.GlobalConfiguration.AutoSetUpConfiguredDrivers(); 

如果我取消注释 DriverSetup 行,我永远不会看到错误。使用 Atata 1.13.0、Atata.WebDriverSetup 1.2.0 和 Selenium 4.0.0 - 有什么想法吗?

--根据要求 - 这是堆栈跟踪:

at System.ThrowHelper.ThrowArgumentOutOfRange_IndexException()
   at System.Collections.Generic.List`1.RemoveAt(Int32 index)
   at System.Collections.Generic.List`1.Remove(T item)
   at Atata.WebDriverSetup.DriverSetupConfigurationBuilder.SetUp()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Atata.WebDriverSetup.DriverSetupConfigurationBuilder.<SetUpAsync>d__11.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Atata.WebDriverSetup.DriverSetup.<AutoSetUpAsync>d__26.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Atata.WebDriverSetup.DriverSetup.<AutoSetUpAsync>d__28.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Atata.WebDriverSetup.DriverSetup.<AutoSetUpSafelyAsync>d__30.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Atata.WebDriverSetup.DriverSetup.AutoSetUpSafely(IEnumerable`1 browserNames)
   at Atata.MethodInfoExtensions.InvokeStaticAsLambda(MethodInfo method, Object[] args)
   at Atata.AtataContextBuilder.InvokeAutoSetUpSafelyMethodOfDriverSetup(IEnumerable`1 browserNames)
   at Atata.AtataContextBuilder.AutoSetUpConfiguredDrivers()
   at Atata.Config.SetUpFixture.GlobalSetUp() in C:\Source\fs.automation\Atata.Config\Atata.Config\SetUpFixture.cs:line 45

Atata.WebDriverSetup v1.2.0 中存在线程同步错误。感谢您报告。它现在应该在 Atata.WebDriverSetup v1.2.1 中修复。请更新程序包并确认此错误不会重现。