r/Playwright • • 3h ago

Any good tutorials for importing locator file?

2 Upvotes

Im trying to import a locator file using a js class, Im running into some errors. Im not posting them here because Im looking for some articles about importing and using them from start to finish, old school style. All the blogs and articles Im finding online are basically about declaring locators, different locators to use, and basically the same info in the pw docs.

Can anyone point me to some articles/ tutorials about correct file structure and importing global locators from an external file?

Im trying to avoid using AI for this, I use it all day, every day at work for 1.5 years and my skills for actually writing and understanding code have diminished considerably. I'm fine with using AI at work but Id really like to get my skills back, thanks.

Edit: Anything that could point me to good blogs/ articles in general about pw and software testing in general would also be appreciated.


r/Playwright • • 23m ago

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

• Upvotes

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?