microsoft / playwright-dotnet

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

[Bug]: HelloWorld NUnit setup ("intro" section in docs) fails with 30seconds timeout #2993

Closed knocte closed 5 days ago

knocte commented 2 weeks ago

Version

1.46.0

Steps to reproduce

Example steps (replace with your own):

  1. Using macOS, follow same exact steps as outlined in the docs (linked from the README file of this repo): https://playwright.dev/dotnet/docs/intro
  2. NOTE: use the "NUnit" tab in the docs.

In particular, this is the content of my .cs file:

using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.Playwright;
using Microsoft.Playwright.NUnit;
using NUnit.Framework;

namespace PlaywrightTests;

[Parallelizable(ParallelScope.Self)]
[TestFixture]
public class ExampleTest : PageTest
{
    [Test]
    public async Task HasTitle()
    {
        await Page.GotoAsync("https://playwright.dev");

        // Expect a title "to contain" a substring.
        await Expect(Page).ToHaveTitleAsync(new Regex("Playwright"));
    }

    [Test]
    public async Task GetStartedLink()
    {
        await Page.GotoAsync("https://playwright.dev");

        // Click the get started link.
        await Page.GetByRole(AriaRole.Link, new() { Name = "Get started" }).ClickAsync();

        // Expects page to have a heading with the name of Installation.
        await Expect(Page.GetByRole(AriaRole.Heading, new() { Name = "Installation" })).ToBeVisibleAsync();
    }
}
  1. Run with dotnet test.

Expected behavior

It should work? No exceptions.

Actual behavior

knocte@knocte-macbook Backend.Playwright % dotnet test
  Determining projects to restore...
/usr/local/share/dotnet/sdk/8.0.201/NuGet.targets(169,5): warning : The folder '/Users/knocte/.nuget/packages/microsoft.testplatform.objectmodel/lib' contains an invalid version. [/Users/knocte/Documents/Code/cosmopolimeet/src/Backend.Playwright/Backend.Playwright.csproj]
  All projects are up-to-date for restore.
/Users/knocte/Documents/Code/cosmopolimeet/src/Backend.Playwright/Backend.Playwright.csproj : warning Undefined: The folder '/Users/knocte/.nuget/packages/microsoft.testplatform.objectmodel/lib' contains an invalid version.
  Backend.Playwright -> /Users/knocte/Documents/Code/cosmopolimeet/src/Backend.Playwright/bin/Debug/net8.0/Backend.Playwright.dll
Test run for /Users/knocte/Documents/Code/cosmopolimeet/src/Backend.Playwright/bin/Debug/net8.0/Backend.Playwright.dll (.NETCoreApp,Version=v8.0)
Microsoft (R) Test Execution Command Line Tool Version 17.9.0 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
  Failed HasTitle [30 s]
  Error Message:
   System.TimeoutException : Timeout 30000ms exceeded.
Call log:
  - navigating to "https://playwright.dev/", waiting until "load"
  Stack Trace:
     at Microsoft.Playwright.Transport.Connection.InnerSendMessageToServerAsync[T](ChannelOwner object, String method, Dictionary`2 dictionary, Boolean keepNulls) in /_/src/Playwright/Transport/Connection.cs:line 206
   at Microsoft.Playwright.Transport.Connection.WrapApiCallAsync[T](Func`1 action, Boolean isInternal) in /_/src/Playwright/Transport/Connection.cs:line 532
   at Microsoft.Playwright.Core.Frame.GotoAsync(String url, FrameGotoOptions options) in /_/src/Playwright/Core/Frame.cs:line 796
   at PlaywrightTests.ExampleTest.HasTitle() in /Users/knocte/Documents/Code/cosmopolimeet/src/Backend.Playwright/UnitTest1.cs:line 16
   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.TestMethodCommand.RunTestMethod(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.TestMethodCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.BeforeAndAfterTestCommand.<>c__DisplayClass1_0.<Execute>b__0()
   at NUnit.Framework.Internal.Commands.DelegatingTestCommand.RunTestMethodInThreadAbortSafeZone(TestExecutionContext context, Action action)

Failed!  - Failed:     1, Passed:     1, Skipped:     0, Total:     2, Duration: 38 s - Backend.Playwright.dll (net8.0)

Additional context

No response

Environment

- Operating System: [macOS Ventura 13.6.1]
- CPU: [arm64]
- Browser: Chromium
- .NET Version (TFM): [net8.0]
mxschmitt commented 2 weeks ago

Your OS looks supported - could you set the DEGBUG=pw:browser,pw:api env var? This might yield more debug information.

Are you by any chance in some corp environment where you need e.g. a proxy in order to access the internet? This would explain it why the navigation to playwright.dev fails.

mxschmitt commented 5 days ago

Closing as part of the triage process since it seemed stale. Please create a new issue with a detailed reproducible or feature request if you still face issues.

knocte commented 3 days ago

Surprisingly enough, when I tried to reproduce this again (with and without the DEBUG env var suggested), I couldn't.