Class PlaywrightOptionsResolver
Options object into the
concrete Playwright/Browser/Context instances.
Both PlaywrightBrowserManager and the Screenplay
BrowseTheWebWithPlaywright ability delegate here so the resolution
logic lives in one place.
Mutation note: resolveLaunchOptions(com.microsoft.playwright.junit.Options) and
resolveContextOptions(com.microsoft.playwright.junit.Options) apply shorthand fields (headless,
channel, baseUrl, ignoreHTTPSErrors) directly onto
the nested objects inside Options. This matches how Playwright's own
JUnit extension behaves. Callers that need isolation should obtain a fresh
Options instance per invocation (e.g. via OptionsFactory.getOptions()).
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.microsoft.playwright.PlaywrightcreatePlaywright(com.microsoft.playwright.junit.Options options) Create aPlaywrightinstance, applyingplaywrightCreateOptionsandtestIdAttributefrom Options.static com.microsoft.playwright.BrowserlaunchOrConnect(com.microsoft.playwright.junit.Options options, com.microsoft.playwright.BrowserType browserType, com.microsoft.playwright.BrowserType.LaunchOptions launchOptions) Launch a browser or connect to a remote endpoint based on the Options.static StringresolveBrowserType(com.microsoft.playwright.junit.Options options, String fallback) Resolve the browser type name from Options, falling back to the given default.static com.microsoft.playwright.Browser.NewContextOptionsresolveContextOptions(com.microsoft.playwright.junit.Options options) Build the effectiveBrowser.NewContextOptionsfrom the given Options.static com.microsoft.playwright.BrowserType.LaunchOptionsresolveLaunchOptions(com.microsoft.playwright.junit.Options options) Build the effectiveBrowserType.LaunchOptionsfrom the given Options.
-
Method Details
-
resolveBrowserType
public static String resolveBrowserType(com.microsoft.playwright.junit.Options options, String fallback) Resolve the browser type name from Options, falling back to the given default.- Parameters:
options- the Playwright Options (may be null)fallback- the default browser type when Options doesn't specify one- Returns:
- a non-null browser type name
-
resolveLaunchOptions
public static com.microsoft.playwright.BrowserType.LaunchOptions resolveLaunchOptions(com.microsoft.playwright.junit.Options options) Build the effectiveBrowserType.LaunchOptionsfrom the given Options.When
options.launchOptionsis present it is used as the base; otherwise a fresh instance is created. Shorthand fieldsheadlessandchannelare then applied on top.- Parameters:
options- the Playwright Options (must not be null)- Returns:
- resolved launch options (never null)
-
resolveContextOptions
public static com.microsoft.playwright.Browser.NewContextOptions resolveContextOptions(com.microsoft.playwright.junit.Options options) Build the effectiveBrowser.NewContextOptionsfrom the given Options.When
options.contextOptionsis present it is used as the base. Shorthand fieldsbaseUrlandignoreHTTPSErrorsare applied on top when set. Returnsnullwhen neither the base nor any shorthand is specified.- Parameters:
options- the Playwright Options (must not be null)- Returns:
- resolved context options, or null if nothing is configured
-
createPlaywright
public static com.microsoft.playwright.Playwright createPlaywright(com.microsoft.playwright.junit.Options options) Create aPlaywrightinstance, applyingplaywrightCreateOptionsandtestIdAttributefrom Options.- Parameters:
options- the Playwright Options (must not be null)- Returns:
- a new Playwright instance
-
launchOrConnect
public static com.microsoft.playwright.Browser launchOrConnect(com.microsoft.playwright.junit.Options options, com.microsoft.playwright.BrowserType browserType, com.microsoft.playwright.BrowserType.LaunchOptions launchOptions) Launch a browser or connect to a remote endpoint based on the Options.When
options.wsEndpointis set and non-empty, a WebSocket connection is established usingoptions.connectOptions. Otherwise the browser is launched locally using the given launch options.- Parameters:
options- the Playwright Options (must not be null)browserType- the resolved BrowserType to launch/connectlaunchOptions- the resolved launch options (used when not connecting)- Returns:
- a connected or launched Browser
-