microsoft / playwright-dotnet

.NET version of the Playwright testing and automation library.
https://playwright.dev/dotnet/
MIT License
2.5k stars 237 forks source link

[Bug]: Firefox Error -> Microsoft.Playwright.TargetClosedException : Target page, context or browser has been closed #3048

Closed vibhubanga closed 21 hours ago

vibhubanga commented 21 hours ago

Version

1.48.0

Steps to reproduce

I created a new xUnit Test Project using .Net 8.0 where I am using Microsoft.Playwright version 1.48.0. However when i am launching playwright for FireFox, I get an error that says Target page, context or browser has been closed

This works fine if i use .net 6 with an older version of playwright 1.34.0. Also when i launch the test, an empty Firefox window opens and does nothing. Also there is a popup window that opens automatically along with the parent window which also does nothing. I have attached the screenshot of the same. Image

Expected behavior

It should work as expected like how it was working with the previous version.

Actual behavior

I get an error whenever a test launches ->

Microsoft.Playwright.TargetClosedException : Target page, context or browser has been closed

Stack Trace:  Connection.InnerSendMessageToServerAsync[T](ChannelOwner object, String method, Dictionary2 dictionary, Boolean keepNulls) line 206 Connection.WrapApiCallAsync[T](Func1 action, Boolean isInternal) line 492 BrowserContext.NewPageAsync() line 486 <b0>d.MoveNext() line 226 --- End of stack trace from previous location --- Connection.WrapApiCallAsync[T](Func1 action, Boolean isInternal) line 535 Browser.NewPageAsync(BrowserNewPageOptions options) line 224 SetupWithLogin.HomepageWithAuthenticationAsync() line 27 SetupWithLogin.HomepageWithAuthenticationAsync() line 41 GenericAdapter1.BlockUntilCompleted() NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaiter) AsyncToSyncAdapter.Await[TResult](Func1 invoke) AsyncToSyncAdapter.Await(Func1 invoke) SetUpTearDownItem.RunSetUpOrTearDownMethod(TestExecutionContext context, IMethodInfo method) SetUpTearDownItem.RunSetUp(TestExecutionContext context) <.ctor>b0(TestExecutionContext context) BeforeTestCommand.Execute(TestExecutionContext context) BeforeTestCommand.Execute(TestExecutionContext context) CompositeWorkItem.PerformOneTimeSetUp()

Additional context

Also apart from the above bug, there is another observation that whenever i use playwright for Chromium, it never launches it in Incognito mode and takes my logged in credentials instead of my code where i try to enter my automation account credentials.

Environment

- Operating System: Windows 11
- CPU: 64
- Browser: Firefox
- .NET Version (TFM): [net8.0]
- Other info:
mxschmitt commented 21 hours ago

This issue is not following the bug template. Please re-file and provide a self-contained reproduction, which we can run locally to reproduce your issue. Thanks for your understanding!