BELLATRIX icon indicating copy to clipboard operation
BELLATRIX copied to clipboard

Exception is shown "Cannot access a disposed object" when using Parallelizable attribute

Open bankova opened this issue 1 year ago • 2 comments

Setup in Bellatrix.Web.GettingStarted:

  1. Add [Parallelizable] in classes LocateElementsTests and WaitElementsTests
  2. In testFrameworkSettings.Debug.json set
"webSettings": {
  "isParallelExecutionEnabled": "true",
"processCleanupSettings": {
  "isParallelExecutionEnabled": "true"
},
  1. Select in the Test Explorer in Visual Studio all tests from both classes and run them all.

Expected: All tests pass.

Actual: Only the tests from one of the classes will pass, the tests from the other will fail. The exception is: OneTimeSetUp: System.ObjectDisposedException : Cannot access a disposed object. Object name: 'System.Net.Http.HttpClient'. In the log even for the tests that have passed the following is displayed:

Standard Error:  ********** OpenQA.Selenium.WebDriverException: An unknown exception was encountered sending an HTTP request to the remote WebDriver server for URL http://127.0.0.1:51887/session/c5a9c64bf9f9a19ec7e92b3b13eada54/window. The exception message was: An error occurred while sending the request. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.. ---> System.Net.Sockets.SocketException (10054): An existing connection was forcibly closed by the remote host. --- End of inner exception stack trace --- at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken) at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Int32>.GetResult(Int16 token) at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo) at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute) --- End of inner exception stack trace --- at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute) at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute) at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) at OpenQA.Selenium.WebDriver.Close() at Bellatrix.Web.Services.DisposeDriverService.Dispose(IWebDriver webDriver, ServicesCollection container) in C:\Users\bankova\Desktop\BELLATRIX-master\src\Bellatrix.Web\services\DisposeDriverService.cs:line 46 **********

bankova avatar Dec 05 '23 16:12 bankova

Hello Kristina,

We have just released the latest version of the framework. One of the issues resolved was the parallel execution, so please download the new source code and try again your scenario.

-Nikolay

n1xan avatar Feb 14 '24 16:02 n1xan

Hi Niki, thank you for the update. The issue is still reproducible, I have tested with the newest version available.

bankova avatar Feb 27 '24 11:02 bankova