microsoft / microsoft/playwright-java

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

Offen
#1,809 1 Kommentar 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

P3-collecting-feedback
Vorherrschende Sprache
Java
Sterne
1.6k
Forks
298
Ø Merge
3 T. 2 Std.
Gemergte PRs (30 T.)
14

Beschreibung

🚀 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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit der JUnit-Support-API, insbesondere com.microsoft.playwright.junit.Options und OptionsFactory, und untersuche anschließend Browser.NewContextOptions. Ermittle, welche Option den Standard-Timeout besitzen sollte und wie dieser die injizierten BrowserContext- und Page-Instanzen erreicht. Die Aufgabe ist erledigt, wenn Benutzer den Timeout zentral über das gezeigte OptionsFactory-Muster konfigurieren können, auch außerhalb von JUnit, wo NewContextOptions verwendet wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
testing-qa
Issue-Typ
Feature
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.