Here's the content of my GlobalSetup - occasionally when I run, the call to AutoSetUpConfiguredDrivers throws an exception:
System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection. (Parameter '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();
If I uncomment the DriverSetup line, I never see the error. Using Atata 1.13.0, Atata.WebDriverSetup 1.2.0 and Selenium 4.0.0 - any ideas?
--As requested - here's the stack trace:
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
There was a thread synchronization bug in Atata.WebDriverSetup v1.2.0. Thanks for reporting it. It should be fixed now in Atata.WebDriverSetup v1.2.1. Please update the package and verify that this error doesn't reproduce.