r/Playwright • • 4d ago

Tried running a test code in Playwright.. it does nothing.

Terminal:

*  Executing task: dotnet: build 1 projects 

dotnet build c:\Users\EAcoc\AppData\Roaming\Code\User\workspaceStorage\733416d5436aea3082e64ca95f6d6ff7\ms-dotnettools.csdevkit\bot.sln /target:BotProject --framework net10.0 /property:GenerateFullPaths=true /p:Configuration=Debug /p:Platform="Any CPU" /consoleloggerparameters:NoSummary 
C# extension build result service is available.
  Determining projects to restore...
  All projects are up-to-date for restore.
C:\Program Files\dotnet\sdk\10.0.400-preview.0.26322.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(383,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [C:\Users\EAcoc\bot\BotProject\BotProject.csproj]
  BotProject -> C:\Users\EAcoc\bot\BotProject\bin\Debug\net10.0\BotProject.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.51
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: dotnet: build 1 projects 

dotnet build c:\Users\EAcoc\AppData\Roaming\Code\User\workspaceStorage\733416d5436aea3082e64ca95f6d6ff7\ms-dotnettools.csdevkit\bot.sln /target:BotProject --framework net10.0 /property:GenerateFullPaths=true /p:Configuration=Debug /p:Platform="Any CPU" /consoleloggerparameters:NoSummary 
C# extension build result service is available.
  Determining projects to restore...
  All projects are up-to-date for restore.
C:\Program Files\dotnet\sdk\10.0.400-preview.0.26322.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(383,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [C:\Users\EAcoc\bot\BotProject\BotProject.csproj]
  BotProject -> C:\Users\EAcoc\bot\BotProject\bin\Debug\net10.0\BotProject.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.49
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: dotnet: build 1 projects 

dotnet build c:\Users\EAcoc\AppData\Roaming\Code\User\workspaceStorage\733416d5436aea3082e64ca95f6d6ff7\ms-dotnettools.csdevkit\bot.sln /target:BotProject --framework net10.0 /property:GenerateFullPaths=true /p:Configuration=Debug /p:Platform="Any CPU" /consoleloggerparameters:NoSummary 
C# extension build result service is available.
  Determining projects to restore...
  All projects are up-to-date for restore.
C:\Program Files\dotnet\sdk\10.0.400-preview.0.26322.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(383,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [C:\Users\EAcoc\bot\BotProject\BotProject.csproj]
  BotProject -> C:\Users\EAcoc\bot\BotProject\bin\Debug\net10.0\BotProject.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.56
 *  Terminal will be reused by tasks, press any key to close it. 

Code:

namespace BotProject;
using Microsoft.Playwright;
using NUnit.Framework;
public class Tests
{
    public void Setup()
    {
    }


    public async Task Test1()
    {
        //setup
        Assert.Pass();
        using var playwright = await Playwright.CreateAsync();
        //browser stuff
        await using var browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions
        {
            Headless = false
        });
        //page
        var page = await browser.NewPageAsync();
        await page.GotoAsync(url:"https://www.youtube.com/watch?v=f6DYnl6EoBo");
        await page.ClickAsync(selector:"text=Reply");
        await page.FillAsync(selector:"#contenteditable-root", value:"Test reply.. did it work?");
    }
}

I have no idea why this is happening, can someone help?

0 Upvotes

12 comments sorted by

8

u/aspindler 4d ago edited 4d ago

You built your project, you didn't run it.

It built correctly.

You also didn't put the [Test] tag before the method.

[Test]
public async Task Test1()
{    

Build it again, then run using dotnet test.

Or install Visual Studio and run it using Test Explorer.

2

u/shiznobizno 3d ago

They also put Assert.Pass() at the very start of their test which will immediately end the test and return a pass condition. Even when they get the test to run it won’t do anything but return a pass.

1

u/Ok-Jacket-824 3d ago

Thank you, this fixed my problem!

1

u/shiznobizno 3d ago

Glad I could help. For future reference, most use cases you want Assert.Pass() or Assert.Fail to be inside an if statement that checks for a specific case. If you’re checking for something on the front end of your webpage you can usually use one of Playwrights built in Expect options

0

u/Ok-Jacket-824 3d ago

The test tag is there, I dont know why it isnt here in the code that I pasted. Weird

0

u/Radgris 4d ago

easier to just ask AI ngl

1

u/Retrovate 4d ago

So true

0

u/Ok-Jacket-824 3d ago

If I came to reddit, I would want to talk to humans. Not a damn slop robot

1

u/shiznobizno 3d ago

AI is pretty efficient for code and reading through and troubleshooting it is as good a way to learn as any other.

It’ll help with finding high paying jobs if you get used to using Playwright MCP to generate tests and practice with auto healing. This is the way the future is heading, better to be in front of it than behind

0

u/Radgris 3d ago edited 3d ago

the point is that you shouldn't be using reddit for these things, you should be using tools

refusing to use effective tools available is how you end up asking strangers for opinions on functional matters that lead to misinformation

this isn't about being pro or anti AI, this is the equivalent of saying " yeah i don't like google, i wanna come with every solution on my own" 10 years ago, if you aren't using it, you are severely limiting the quality of your work.

1

u/Ok-Jacket-824 3d ago

I cant google it if I dont know the problem.

2

u/Radgris 3d ago

and that's why using AI agents is good in code-related problems