Package io.quarkiverse.playwright
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:
-
WithPlaywright
InjectPlaywright
QuarkusTestResourceConfigurableLifecycleManager
-
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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
init
(WithPlaywright withPlaywright) Initializes the Playwright manager with configuration fromWithPlaywright
.void
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.start()
Starts the Playwright environment and configures the browser and context based onWithPlaywright
options.void
stop()
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
Initializes the Playwright manager with configuration fromWithPlaywright
.- Specified by:
init
in interfaceio.quarkus.test.common.QuarkusTestResourceConfigurableLifecycleManager<WithPlaywright>
- Parameters:
withPlaywright
- the Playwright configuration options
-
init
Not used in this implementation. Throws an exception to ensure only@WithPlaywright
annotation is used for initialization.- Specified by:
init
in interfaceio.quarkus.test.common.QuarkusTestResourceLifecycleManager
- Parameters:
initArgs
- ignored initialization arguments- Throws:
IllegalStateException
- always, as this method is unsupported
-
start
Starts the Playwright environment and configures the browser and context based onWithPlaywright
options.- Specified by:
start
in interfaceio.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 interfaceio.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
, andPlaywright
into appropriately annotated fields.- Specified by:
inject
in interfaceio.quarkus.test.common.QuarkusTestResourceLifecycleManager
- Parameters:
testInjector
- the test injector responsible for dependency injection
-