System.NullReferenceException at Microsoft.Playwright.NUnit.BrowserService
See original GitHub issueI am trying to follow the “First test” instructions here but when I run dotnet test – NUnit.NumberOfTestWorkers=5 I get the following error:
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Failed ShouldAdd [4 s]
Error Message:
System.NullReferenceException : Object reference not set to an instance of an object.
Stack Trace:
at Microsoft.Playwright.NUnit.BrowserService.<>c__DisplayClass4_0.<<Register>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.Playwright.NUnit.WorkerAwareTest.RegisterService[T](String name, Func`1 factory)
at Microsoft.Playwright.NUnit.BrowserService.Register(WorkerAwareTest test, IBrowserType browserType)
at Microsoft.Playwright.NUnit.BrowserTest.BrowserSetup()
at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.GetResult()
at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUpOrTearDownMethod(TestExecutionContext context, MethodInfo method)
at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUp(TestExecutionContext context)
at NUnit.Framework.Internal.Commands.SetUpTearDownCommand.<>c__DisplayClass0_0.<.ctor>b__0(TestExecutionContext context)
at NUnit.Framework.Internal.Commands.BeforeAndAfterTestCommand.<>c__DisplayClass1_0.<Execute>b__0()
at NUnit.Framework.Internal.Commands.BeforeAndAfterTestCommand.RunTestMethodInThreadAbortSafeZone(TestExecutionContext context, Action action)
Failed ShouldMultiply [< 1 ms]
Error Message:
System.NullReferenceException : Object reference not set to an instance of an object.
Stack Trace:
at Microsoft.Playwright.NUnit.BrowserService.<>c__DisplayClass4_0.<<Register>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.Playwright.NUnit.WorkerAwareTest.RegisterService[T](String name, Func`1 factory)
at Microsoft.Playwright.NUnit.BrowserService.Register(WorkerAwareTest test, IBrowserType browserType)
at Microsoft.Playwright.NUnit.BrowserTest.BrowserSetup()
at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.GetResult()
at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUpOrTearDownMethod(TestExecutionContext context, MethodInfo method)
at NUnit.Framework.Internal.Commands.SetUpTearDownItem.RunSetUp(TestExecutionContext context)
at NUnit.Framework.Internal.Commands.SetUpTearDownCommand.<>c__DisplayClass0_0.<.ctor>b__0(TestExecutionContext context)
at NUnit.Framework.Internal.Commands.BeforeAndAfterTestCommand.<>c__DisplayClass1_0.<Execute>b__0()
at NUnit.Framework.Internal.Commands.BeforeAndAfterTestCommand.RunTestMethodInThreadAbortSafeZone(TestExecutionContext context, Action action)
Failed! - Failed: 2, Passed: 0, Skipped: 0, Total: 2, Duration: 4 s - Rfsmart.PointOfCare.PlaywrightTests.dll (net5.0)
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
System.MissingMethodException : Method not found: ...
I've added the dependencies Microsoft.Playwright.NUnit v1.31.1 · I've installed the browsers 'pwsh bin/Debug/net7.0/playwright.ps1 install' · I've ...
Read more >How can I fix the error: System.NullReferenceException
A NullReferenceException exception is thrown by a method that is passed null. Learn more. For more information and examples, take a look at...
Read more >Use Microsoft.Playwright.NUnit.BrowserService in ...
Want to learn how to use BrowserService class in Microsoft.Playwright.NUnit package for your next Playwright-dotnet project? LambdaTest Automation Testing ...
Read more >NullReferenceException when using NUnit
I'm trying to set up unit tests for a card game application, but my code is throwing a NullReferenceException: Object reference not set...
Read more >Test Runners | Playwright .NET
Playwright provides base classes to write tests with NUnit via the Microsoft.Playwright.NUnit package. Creating an NUnit project. # Create a new project
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That indeed was my issue. Thank you.
@SimonCropp see #1573 - we now fail the test, if this happens. I considered throwing an exception in the base implementation, but I didn’t see the value and it just introduces a potential (unwarranted) behavioural change.