microsoft / microsoft/playwright-dotnet

[Documentation] Custom selector engines before page is created

Open
#2,750 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P3-collecting-feedback
Dominant language
C#
Stars
3k
Forks
304
Avg merge
20h 47m
Merged PRs (30d)
6

Description

The documentation (both in code and https://playwright.dev/dotnet/docs/extensibility) states:
Selectors must be registered before creating the page.

However the code below works, in a TestClass inheriting from PageTest.
Isn't the page already created when entering this method, given that actions are performed on it?

[TestInitialize]
public async Task InitializeTest()
{
    await RegisterCustomSelectors(); // register here
    await Page.GotoAsync("/");
    await Page.Locator("myengine=test").FillAsync("hi"); // this works!
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the custom selector registration guidance in the code and the .NET extensibility documentation. Trace the PageTest lifecycle around TestInitialize, RegisterCustomSelectors, and Page to compare the stated requirement with the example. Done means both documentation locations accurately explain when registration is valid and why the shown test works.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
documentation, testing
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.