microsoft / microsoft/playwright-java

[Feature]: Java / JUnit - add possibility to configure default timeout

Open
#1,809 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

P3-collecting-feedback
Dominant language
Java
Stars
1.6k
Forks
298
Avg merge
3d 2h
Merged PRs (30d)
14

Description

🚀 Feature Request

Status Quo

JUnit support (https://playwright.dev/java/docs/junit) allows to inject a pre-configured instances of Page, BrowserContext, etc. into a test method. Users are able to configure various settings, but not the default timeout on the BrowserContext. As a result, users must call context.setDefaultTimeout or page.setTimout on each injected instance, which is both error prone and increases the amount of ceremonies inside the test code, distracting from its business goals.

Improvement Suggestion

Extend com.microsoft.playwright.junit.Options or com.microsoft.playwright.Browser.NewContextOptions with possibility to set the default timeout. The latter would probably be a better choice, as it would also cover non-JUnit environments, where NewContextOptions could be centrally populated.

Example

In the test class - same as today:

@UsePlaywright(MyOptions.class)
class MyTest {
...
}

In the OptionsFactory - new possibility to set the default timeout:

class MyOptions extends OptionsFactory {
   @Override
   public Options getOptions() {
       return new Options()
           ....
          .setContextOptions(
            new Browser.NewContextOptions()
                ....
                .setDefaultTimeout(10_000)
        );
   }
Motivation

Provide users with possibility to centrally manage all defaults for the created BrowserContext / Page.

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 JUnit support API, especially com.microsoft.playwright.junit.Options and OptionsFactory, then inspect Browser.NewContextOptions. Determine which option should own the default timeout and how it reaches injected BrowserContext and Page instances. Done means users can configure the timeout centrally through the shown OptionsFactory pattern, including outside JUnit where NewContextOptions is used.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing-qa
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.