I have some UI test written in MS Test 2 framework.
The test runs fine when I run it from Visual Studio 2022's test explorer.
When I try to debug the test I'm getting:
Microsoft.Playwright.PlaywrightException: Connection closed (System.Threading.ThreadAbortException: System error.
at System.IO.Strategies.BufferedFileStreamStrategy.WriteToNonSeekableAsync(ReadOnlyMemory`1 source, CancellationToken cancellationToken)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.IO.Strategies.BufferedFileStreamStrategy.WriteToNonSeekableAsync(ReadOnlyMemory`1 source, CancellationToken cancellationToken)
at System.IO.Strategies.BufferedFileStreamStrategy.WriteAsync(ReadOnlyMemory`1 buffer, CancellationToken cancellationToken)
at System.IO.FileStream.WriteAsync(ReadOnlyMemory`1 buffer, CancellationToken cancellationToken)
at Microsoft.Playwright.Transport.StdIOTransport.SendAsync(String message))
Stack Trace:
Connection.SendMessageToServerAsync[T](String guid, String method, Object args)
Frame.WaitForFunctionAsync(String expression, Object arg, FrameWaitForFunctionOptions options)
MyTest.MyAsyncMethod() line 23
ThreadOperations.ExecuteWithAbortSafety(Action action)
on following call to WaitForFunctionAsync:
var jshandle = await Page.WaitForFunctionAsync(script,
null,
new() { Timeout = 5000, PollingInterval = 300 });
The error occurs only if the breakpoint is hit before the call.
I'm experiencing similar behavior with QuerySelectorAsync().
How can I debug playwright tests?!