microsoft / microsoft/playwright-dotnet

[Feature]: Use browser in OneTimeSetUp and OneTimeTearDown

Open
#3,216 0 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

🚀 Feature Request

Very often we need to make some actions during OneTimeSetUp and make some cleaning in OneTimeTearDown and we need to open the same browser that we have.
Now it is possible via work-around for OneTimeTearDown, but absently not possible for OneTimeSetUp.

Example
[TestFixture]
public class MyTests : PlaywrightTest
{
    [OneTimeSetUp]
    public async Task OneTimeSetUp()
    {
        // Access to fixture-level browser instances
        var page = await FixtureBrowser.NewPageAsync();
        
        // Perform global setup
        
    }
}
Motivation

Now we need to duplicate the logic to run browser to some place to be able to run playwright in OneTimeSetUp, which can cause a lot of issues or just do not use adaptor at all.

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 by tracing the test adapter's lifecycle around OneTimeSetUp, OneTimeTearDown, and fixture-level browser instances. Determine how the existing teardown workaround starts or exposes the browser, then define the equivalent setup path; done means both callbacks can access the same browser without duplicated launch logic, with coverage for the lifecycle behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.