Skip to content

Navigation Menu

Sign in
Sign up

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

Open

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      AltStyle によって変換されたページ (->オリジナル) /