Class QuarkusPlaywrightManager

java.lang.Object
io.quarkiverse.playwright.QuarkusPlaywrightManager
All Implemented Interfaces:
io.quarkus.test.common.QuarkusTestResourceConfigurableLifecycleManager<WithPlaywright>, io.quarkus.test.common.QuarkusTestResourceLifecycleManager

public class QuarkusPlaywrightManager extends Object implements io.quarkus.test.common.QuarkusTestResourceConfigurableLifecycleManager<WithPlaywright>
Manages the lifecycle of a Playwright instance in Quarkus tests.

This class implements QuarkusTestResourceConfigurableLifecycleManager and is responsible for initializing and configuring Playwright resources, such as the Browser, BrowserContext, and Playwright instance, according to the settings specified in the WithPlaywright annotation.

This manager supports injecting Playwright resources into test classes marked with the @InjectPlaywright annotation, allowing easy access to BrowserContext, Browser, or Playwright instances.

Since:
1.0
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.quarkus.test.common.QuarkusTestResourceLifecycleManager

    io.quarkus.test.common.QuarkusTestResourceLifecycleManager.Context, io.quarkus.test.common.QuarkusTestResourceLifecycleManager.TestInjector
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    init(WithPlaywright withPlaywright)
    Initializes the Playwright manager with configuration from WithPlaywright.
    void
    init(Map<String,String> initArgs)
    Not used in this implementation.
    void
    inject(io.quarkus.test.common.QuarkusTestResourceLifecycleManager.TestInjector testInjector)
    Injects Playwright resources into fields annotated with @InjectPlaywright in test classes.
    Starts the Playwright environment and configures the browser and context based on WithPlaywright options.
    void
    Closes and cleans up the Playwright resources, ensuring proper shutdown.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.quarkus.test.common.QuarkusTestResourceLifecycleManager

    inject, order, setContext
  • Constructor Details

    • QuarkusPlaywrightManager

      public QuarkusPlaywrightManager()
  • Method Details

    • init

      public void init(WithPlaywright withPlaywright)
      Initializes the Playwright manager with configuration from WithPlaywright.
      Specified by:
      init in interface io.quarkus.test.common.QuarkusTestResourceConfigurableLifecycleManager<WithPlaywright>
      Parameters:
      withPlaywright - the Playwright configuration options
    • init

      public void init(Map<String,String> initArgs)
      Not used in this implementation. Throws an exception to ensure only @WithPlaywright annotation is used for initialization.
      Specified by:
      init in interface io.quarkus.test.common.QuarkusTestResourceLifecycleManager
      Parameters:
      initArgs - ignored initialization arguments
      Throws:
      IllegalStateException - always, as this method is unsupported
    • start

      public Map<String,String> start()
      Starts the Playwright environment and configures the browser and context based on WithPlaywright options.
      Specified by:
      start in interface io.quarkus.test.common.QuarkusTestResourceLifecycleManager
      Returns:
      an empty map as no additional environment variables are required
    • stop

      public void stop()
      Closes and cleans up the Playwright resources, ensuring proper shutdown.
      Specified by:
      stop in interface io.quarkus.test.common.QuarkusTestResourceLifecycleManager
    • inject

      public void inject(io.quarkus.test.common.QuarkusTestResourceLifecycleManager.TestInjector testInjector)
      Injects Playwright resources into fields annotated with @InjectPlaywright in test classes.

      This method supports injection of BrowserContext, Browser, and Playwright into appropriately annotated fields.

      Specified by:
      inject in interface io.quarkus.test.common.QuarkusTestResourceLifecycleManager
      Parameters:
      testInjector - the test injector responsible for dependency injection