Skip to content

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

@bankova

Description

@bankova

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.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
**********

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions