You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am running tests using .Net and NUnit. I have some code that creates some state that the individual tests in the same file will share and use. Once that has been set up, the individual tests are run. Some of the tests use the Order attribute because they are sensitive to order, others do not need it. I would like to use a OneTimeTearDown block to clean the state up, but when I try to use Page in it I get the error below. I am currently working around this issue by using a test with a name that starts with Z (to force it to run last) for the cleanup, but that's not ideal.
TearDown : Microsoft.Playwright.PlaywrightException : Target page, context or browser has been closed
StackTrace: --TearDown
at Microsoft.Playwright.Transport.Connection.InnerSendMessageToServerAsync[T](String guid, String method, Object args) in /_/src/Playwright/Transport/Connection.cs:line 163
at Microsoft.Playwright.Transport.Connection.WrapApiCallAsync[T](Func`1 action, Boolean isInternal)
at Microsoft.Playwright.Core.Frame.GotoAsync(String url, FrameGotoOptions options) in /_/src/Playwright/Core/Frame.cs:line 544
at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.BlockUntilCompleted()
at NUnit.Framework.Internal.MessagePumpStrategy.NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaiter)
at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUpOrTearDownMethod(TestExecutionContext context, IMethodInfo method)
at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunTearDown(TestExecutionContext context)```
The text was updated successfully, but these errors were encountered:
[OneTimeTearDown] runs after the entire line of [TearDown]'s finish, so I don't think this is possible. I would add [Order] to all the tests, and give your cleanup method [Order(int.MaxValue)]
I am running tests using .Net and NUnit. I have some code that creates some state that the individual tests in the same file will share and use. Once that has been set up, the individual tests are run. Some of the tests use the
Order
attribute because they are sensitive to order, others do not need it. I would like to use aOneTimeTearDown
block to clean the state up, but when I try to usePage
in it I get the error below. I am currently working around this issue by using a test with a name that starts withZ
(to force it to run last) for the cleanup, but that's not ideal.The text was updated successfully, but these errors were encountered: