question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.NullReferenceException at Microsoft.Playwright.NUnit.BrowserService

See original GitHub issue

I 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:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
beamsjrcommented, Jun 21, 2021

That indeed was my issue. Thank you.

0reactions
avodovnikcommented, Jun 21, 2021

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found