Package com.microsoft.playwright
Class BrowserType.LaunchPersistentContextOptions
java.lang.Object
com.microsoft.playwright.BrowserType.LaunchPersistentContextOptions
- Enclosing interface:
BrowserType
-
Field Summary
FieldsModifier and TypeFieldDescriptionWhether to automatically download all the attachments.Additional arguments to pass to the browser instance.When usingPage.navigate(),Page.route(),Page.waitForURL(),Page.waitForRequest(), orPage.waitForResponse()it takes the base URL in consideration by using theURL()constructor for building the corresponding URL.Toggles bypassing page's Content-Security-Policy.Browser distribution channel.Enable Chromium sandboxing.Emulates"prefers-colors-scheme"media feature, supported values are"light","dark","no-preference".Specify device scale factor (can be thought of as dpr).**Chromium-only** Whether to auto-open a Developer Tools panel for each tab.If specified, accepted downloads are downloaded into this directory.Specify environment variables that will be visible to the browser.Path to a browser executable to run instead of the bundled one.An object containing additional HTTP headers to be sent with every request.Emulates"forced-colors"media feature, supported values are"active","none".Close the browser process on SIGHUP.Close the browser process on Ctrl-C.Close the browser process on SIGTERM.Specifies if viewport supports touch events.Whether to run browser in headless mode.Credentials for HTTP authentication.Iftrue, Playwright does not pass its own configurations args and only uses the ones fromargs.Iftrue, Playwright does not pass its own configurations args and only uses the ones fromargs.Whether to ignore HTTPS errors when sending network requests.Whether themeta viewporttag is taken into account and touch events are enabled.Whether or not to enable JavaScript in the context.Specify user locale, for exampleen-GB,de-DE, etc.Whether to emulate network being offline.A list of permissions to grant to all pages in this context.Network proxy settings.Optional setting to control resource content management.When set tominimal, only record information necessary for routing from HAR.Optional setting to control whether to omit request content from the HAR.Enables HAR recording for all pages into the specified HAR file on the filesystem.Enables video recording for all pages into the specified directory.Dimensions of the recorded videos.Emulates"prefers-reduced-motion"media feature, supported values are"reduce","no-preference".Emulates consistent window screen size available inside web page viawindow.screen.Whether to allow sites to register Service workers.Slows down Playwright operations by the specified amount of milliseconds.If set to true, enables strict selectors mode for this context.Maximum time in milliseconds to wait for the browser instance to start.Changes the timezone of the context.If specified, traces are saved into this directory.Specific user agent to use in this context.Emulates consistent viewport for each page. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionsetAcceptDownloads(boolean acceptDownloads) Whether to automatically download all the attachments.Additional arguments to pass to the browser instance.setBaseURL(String baseURL) When usingPage.navigate(),Page.route(),Page.waitForURL(),Page.waitForRequest(), orPage.waitForResponse()it takes the base URL in consideration by using theURL()constructor for building the corresponding URL.setBypassCSP(boolean bypassCSP) Toggles bypassing page's Content-Security-Policy.setChannel(BrowserChannel channel) Deprecated.setChannel(String channel) Browser distribution channel.setChromiumSandbox(boolean chromiumSandbox) Enable Chromium sandboxing.setColorScheme(ColorScheme colorScheme) Emulates"prefers-colors-scheme"media feature, supported values are"light","dark","no-preference".setDeviceScaleFactor(double deviceScaleFactor) Specify device scale factor (can be thought of as dpr).setDevtools(boolean devtools) **Chromium-only** Whether to auto-open a Developer Tools panel for each tab.setDownloadsPath(Path downloadsPath) If specified, accepted downloads are downloaded into this directory.Specify environment variables that will be visible to the browser.setExecutablePath(Path executablePath) Path to a browser executable to run instead of the bundled one.setExtraHTTPHeaders(Map<String, String> extraHTTPHeaders) An object containing additional HTTP headers to be sent with every request.setForcedColors(ForcedColors forcedColors) Emulates"forced-colors"media feature, supported values are"active","none".setGeolocation(double latitude, double longitude) setGeolocation(Geolocation geolocation) setHandleSIGHUP(boolean handleSIGHUP) Close the browser process on SIGHUP.setHandleSIGINT(boolean handleSIGINT) Close the browser process on Ctrl-C.setHandleSIGTERM(boolean handleSIGTERM) Close the browser process on SIGTERM.setHasTouch(boolean hasTouch) Specifies if viewport supports touch events.setHeadless(boolean headless) Whether to run browser in headless mode.setHttpCredentials(HttpCredentials httpCredentials) Credentials for HTTP authentication.setHttpCredentials(String username, String password) Credentials for HTTP authentication.setIgnoreAllDefaultArgs(boolean ignoreAllDefaultArgs) Iftrue, Playwright does not pass its own configurations args and only uses the ones fromargs.setIgnoreDefaultArgs(List<String> ignoreDefaultArgs) Iftrue, Playwright does not pass its own configurations args and only uses the ones fromargs.setIgnoreHTTPSErrors(boolean ignoreHTTPSErrors) Whether to ignore HTTPS errors when sending network requests.setIsMobile(boolean isMobile) Whether themeta viewporttag is taken into account and touch events are enabled.setJavaScriptEnabled(boolean javaScriptEnabled) Whether or not to enable JavaScript in the context.Specify user locale, for exampleen-GB,de-DE, etc.setOffline(boolean offline) Whether to emulate network being offline.setPermissions(List<String> permissions) A list of permissions to grant to all pages in this context.Network proxy settings.Network proxy settings.setRecordHarContent(HarContentPolicy recordHarContent) Optional setting to control resource content management.setRecordHarMode(HarMode recordHarMode) When set tominimal, only record information necessary for routing from HAR.setRecordHarOmitContent(boolean recordHarOmitContent) Optional setting to control whether to omit request content from the HAR.setRecordHarPath(Path recordHarPath) Enables HAR recording for all pages into the specified HAR file on the filesystem.setRecordHarUrlFilter(String recordHarUrlFilter) setRecordHarUrlFilter(Pattern recordHarUrlFilter) setRecordVideoDir(Path recordVideoDir) Enables video recording for all pages into the specified directory.setRecordVideoSize(int width, int height) Dimensions of the recorded videos.setRecordVideoSize(RecordVideoSize recordVideoSize) Dimensions of the recorded videos.setReducedMotion(ReducedMotion reducedMotion) Emulates"prefers-reduced-motion"media feature, supported values are"reduce","no-preference".setScreenSize(int width, int height) Emulates consistent window screen size available inside web page viawindow.screen.setScreenSize(ScreenSize screenSize) Emulates consistent window screen size available inside web page viawindow.screen.setServiceWorkers(ServiceWorkerPolicy serviceWorkers) Whether to allow sites to register Service workers.setSlowMo(double slowMo) Slows down Playwright operations by the specified amount of milliseconds.setStrictSelectors(boolean strictSelectors) If set to true, enables strict selectors mode for this context.setTimeout(double timeout) Maximum time in milliseconds to wait for the browser instance to start.setTimezoneId(String timezoneId) Changes the timezone of the context.setTracesDir(Path tracesDir) If specified, traces are saved into this directory.setUserAgent(String userAgent) Specific user agent to use in this context.setViewportSize(int width, int height) Emulates consistent viewport for each page.setViewportSize(ViewportSize viewportSize) Emulates consistent viewport for each page.
-
Field Details
-
acceptDownloads
Whether to automatically download all the attachments. Defaults totruewhere all the downloads are accepted. -
args
Additional arguments to pass to the browser instance. The list of Chromium flags can be found here. -
baseURL
When usingPage.navigate(),Page.route(),Page.waitForURL(),Page.waitForRequest(), orPage.waitForResponse()it takes the base URL in consideration by using theURL()constructor for building the corresponding URL. Unset by default. Examples:- baseURL:
http://localhost:3000and navigating to/bar.htmlresults inhttp://localhost:3000/bar.html - baseURL:
http://localhost:3000/foo/and navigating to./bar.htmlresults inhttp://localhost:3000/foo/bar.html - baseURL:
http://localhost:3000/foo(without trailing slash) and navigating to./bar.htmlresults inhttp://localhost:3000/bar.html
- baseURL:
-
bypassCSP
Toggles bypassing page's Content-Security-Policy. Defaults tofalse. -
channel
Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge", "msedge-beta", "msedge-dev", "msedge-canary". Read more about using Google Chrome and Microsoft Edge. -
chromiumSandbox
Enable Chromium sandboxing. Defaults tofalse. -
colorScheme
Emulates"prefers-colors-scheme"media feature, supported values are"light","dark","no-preference". SeePage.emulateMedia()for more details. Passingnullresets emulation to system defaults. Defaults to"light". -
deviceScaleFactor
Specify device scale factor (can be thought of as dpr). Defaults to1. Learn more about emulating devices with device scale factor. -
devtools
**Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option istrue, theheadlessoption will be setfalse. -
downloadsPath
If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in is closed. -
env
Specify environment variables that will be visible to the browser. Defaults toprocess.env. -
executablePath
Path to a browser executable to run instead of the bundled one. IfexecutablePathis a relative path, then it is resolved relative to the current working directory. Note that Playwright only works with the bundled Chromium, Firefox or WebKit, use at your own risk. -
extraHTTPHeaders
An object containing additional HTTP headers to be sent with every request. Defaults to none. -
forcedColors
Emulates"forced-colors"media feature, supported values are"active","none". SeePage.emulateMedia()for more details. Passingnullresets emulation to system defaults. Defaults to"none". -
geolocation
-
handleSIGHUP
Close the browser process on SIGHUP. Defaults totrue. -
handleSIGINT
Close the browser process on Ctrl-C. Defaults totrue. -
handleSIGTERM
Close the browser process on SIGTERM. Defaults totrue. -
hasTouch
Specifies if viewport supports touch events. Defaults to false. Learn more about mobile emulation. -
headless
-
httpCredentials
Credentials for HTTP authentication. If no origin is specified, the username and password are sent to any servers upon unauthorized responses. -
ignoreAllDefaultArgs
Iftrue, Playwright does not pass its own configurations args and only uses the ones fromargs. Dangerous option; use with care. Defaults tofalse. -
ignoreDefaultArgs
Iftrue, Playwright does not pass its own configurations args and only uses the ones fromargs. Dangerous option; use with care. -
ignoreHTTPSErrors
Whether to ignore HTTPS errors when sending network requests. Defaults tofalse. -
isMobile
Whether themeta viewporttag is taken into account and touch events are enabled. isMobile is a part of device, so you don't actually need to set it manually. Defaults tofalseand is not supported in Firefox. Learn more about mobile emulation. -
javaScriptEnabled
Whether or not to enable JavaScript in the context. Defaults totrue. Learn more about disabling JavaScript. -
locale
Specify user locale, for exampleen-GB,de-DE, etc. Locale will affectnavigator.languagevalue,Accept-Languagerequest header value as well as number and date formatting rules. Defaults to the system default locale. Learn more about emulation in our emulation guide. -
offline
Whether to emulate network being offline. Defaults tofalse. Learn more about network emulation. -
permissions
A list of permissions to grant to all pages in this context. SeeBrowserContext.grantPermissions()for more details. Defaults to none. -
proxy
Network proxy settings. -
recordHarContent
Optional setting to control resource content management. Ifomitis specified, content is not persisted. Ifattachis specified, resources are persisted as separate files and all of these files are archived along with the HAR file. Defaults toembed, which stores content inline the HAR file as per HAR specification. -
recordHarMode
When set tominimal, only record information necessary for routing from HAR. This omits sizes, timing, page, cookies, security and other types of HAR information that are not used when replaying from HAR. Defaults tofull. -
recordHarOmitContent
Optional setting to control whether to omit request content from the HAR. Defaults tofalse. -
recordHarPath
Enables HAR recording for all pages into the specified HAR file on the filesystem. If not specified, the HAR is not recorded. Make sure to callBrowserContext.close()for the HAR to be saved. -
recordHarUrlFilter
-
recordVideoDir
Enables video recording for all pages into the specified directory. If not specified videos are not recorded. Make sure to callBrowserContext.close()for videos to be saved. -
recordVideoSize
Dimensions of the recorded videos. If not specified the size will be equal toviewportscaled down to fit into 800x800. Ifviewportis not configured explicitly the video size defaults to 800x450. Actual picture of each page will be scaled down if necessary to fit the specified size. -
reducedMotion
Emulates"prefers-reduced-motion"media feature, supported values are"reduce","no-preference". SeePage.emulateMedia()for more details. Passingnullresets emulation to system defaults. Defaults to"no-preference". -
screenSize
Emulates consistent window screen size available inside web page viawindow.screen. Is only used when theviewportis set. -
serviceWorkers
Whether to allow sites to register Service workers. Defaults to"allow".-
"allow": Service Workers can be registered. -
"block": Playwright will block all registration of Service Workers.
-
-
slowMo
Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on. -
strictSelectors
If set to true, enables strict selectors mode for this context. In the strict selectors mode all operations on selectors that imply single target DOM element will throw when more than one element matches the selector. This option does not affect any Locator APIs (Locators are always strict). Defaults tofalse. SeeLocatorto learn more about the strict mode. -
timeout
Maximum time in milliseconds to wait for the browser instance to start. Defaults to30000(30 seconds). Pass0to disable timeout. -
timezoneId
Changes the timezone of the context. See ICU's metaZones.txt for a list of supported timezone IDs. Defaults to the system timezone. -
tracesDir
If specified, traces are saved into this directory. -
userAgent
Specific user agent to use in this context. -
viewportSize
Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Usenullto disable the consistent viewport emulation. Learn more about viewport emulation.NOTE: The
nullvalue opts out from the default presets, makes viewport depend on the host window size defined by the operating system. It makes the execution of the tests non-deterministic.
-
-
Constructor Details
-
LaunchPersistentContextOptions
public LaunchPersistentContextOptions()
-
-
Method Details
-
setAcceptDownloads
Whether to automatically download all the attachments. Defaults totruewhere all the downloads are accepted. -
setArgs
Additional arguments to pass to the browser instance. The list of Chromium flags can be found here. -
setBaseURL
When usingPage.navigate(),Page.route(),Page.waitForURL(),Page.waitForRequest(), orPage.waitForResponse()it takes the base URL in consideration by using theURL()constructor for building the corresponding URL. Unset by default. Examples:- baseURL:
http://localhost:3000and navigating to/bar.htmlresults inhttp://localhost:3000/bar.html - baseURL:
http://localhost:3000/foo/and navigating to./bar.htmlresults inhttp://localhost:3000/foo/bar.html - baseURL:
http://localhost:3000/foo(without trailing slash) and navigating to./bar.htmlresults inhttp://localhost:3000/bar.html
- baseURL:
-
setBypassCSP
Toggles bypassing page's Content-Security-Policy. Defaults tofalse. -
setChannel
Deprecated. -
setChannel
Browser distribution channel. Supported values are "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge", "msedge-beta", "msedge-dev", "msedge-canary". Read more about using Google Chrome and Microsoft Edge. -
setChromiumSandbox
Enable Chromium sandboxing. Defaults tofalse. -
setColorScheme
Emulates"prefers-colors-scheme"media feature, supported values are"light","dark","no-preference". SeePage.emulateMedia()for more details. Passingnullresets emulation to system defaults. Defaults to"light". -
setDeviceScaleFactor
Specify device scale factor (can be thought of as dpr). Defaults to1. Learn more about emulating devices with device scale factor. -
setDevtools
**Chromium-only** Whether to auto-open a Developer Tools panel for each tab. If this option istrue, theheadlessoption will be setfalse. -
setDownloadsPath
If specified, accepted downloads are downloaded into this directory. Otherwise, temporary directory is created and is deleted when browser is closed. In either case, the downloads are deleted when the browser context they were created in is closed. -
setEnv
Specify environment variables that will be visible to the browser. Defaults toprocess.env. -
setExecutablePath
Path to a browser executable to run instead of the bundled one. IfexecutablePathis a relative path, then it is resolved relative to the current working directory. Note that Playwright only works with the bundled Chromium, Firefox or WebKit, use at your own risk. -
setExtraHTTPHeaders
public BrowserType.LaunchPersistentContextOptions setExtraHTTPHeaders(Map<String, String> extraHTTPHeaders) An object containing additional HTTP headers to be sent with every request. Defaults to none. -
setForcedColors
Emulates"forced-colors"media feature, supported values are"active","none". SeePage.emulateMedia()for more details. Passingnullresets emulation to system defaults. Defaults to"none". -
setGeolocation
-
setGeolocation
-
setHandleSIGHUP
Close the browser process on SIGHUP. Defaults totrue. -
setHandleSIGINT
Close the browser process on Ctrl-C. Defaults totrue. -
setHandleSIGTERM
Close the browser process on SIGTERM. Defaults totrue. -
setHasTouch
Specifies if viewport supports touch events. Defaults to false. Learn more about mobile emulation. -
setHeadless
-
setHttpCredentials
public BrowserType.LaunchPersistentContextOptions setHttpCredentials(String username, String password) Credentials for HTTP authentication. If no origin is specified, the username and password are sent to any servers upon unauthorized responses. -
setHttpCredentials
public BrowserType.LaunchPersistentContextOptions setHttpCredentials(HttpCredentials httpCredentials) Credentials for HTTP authentication. If no origin is specified, the username and password are sent to any servers upon unauthorized responses. -
setIgnoreAllDefaultArgs
public BrowserType.LaunchPersistentContextOptions setIgnoreAllDefaultArgs(boolean ignoreAllDefaultArgs) Iftrue, Playwright does not pass its own configurations args and only uses the ones fromargs. Dangerous option; use with care. Defaults tofalse. -
setIgnoreDefaultArgs
public BrowserType.LaunchPersistentContextOptions setIgnoreDefaultArgs(List<String> ignoreDefaultArgs) Iftrue, Playwright does not pass its own configurations args and only uses the ones fromargs. Dangerous option; use with care. -
setIgnoreHTTPSErrors
Whether to ignore HTTPS errors when sending network requests. Defaults tofalse. -
setIsMobile
Whether themeta viewporttag is taken into account and touch events are enabled. isMobile is a part of device, so you don't actually need to set it manually. Defaults tofalseand is not supported in Firefox. Learn more about mobile emulation. -
setJavaScriptEnabled
Whether or not to enable JavaScript in the context. Defaults totrue. Learn more about disabling JavaScript. -
setLocale
Specify user locale, for exampleen-GB,de-DE, etc. Locale will affectnavigator.languagevalue,Accept-Languagerequest header value as well as number and date formatting rules. Defaults to the system default locale. Learn more about emulation in our emulation guide. -
setOffline
Whether to emulate network being offline. Defaults tofalse. Learn more about network emulation. -
setPermissions
A list of permissions to grant to all pages in this context. SeeBrowserContext.grantPermissions()for more details. Defaults to none. -
setProxy
Network proxy settings. -
setProxy
Network proxy settings. -
setRecordHarContent
public BrowserType.LaunchPersistentContextOptions setRecordHarContent(HarContentPolicy recordHarContent) Optional setting to control resource content management. Ifomitis specified, content is not persisted. Ifattachis specified, resources are persisted as separate files and all of these files are archived along with the HAR file. Defaults toembed, which stores content inline the HAR file as per HAR specification. -
setRecordHarMode
When set tominimal, only record information necessary for routing from HAR. This omits sizes, timing, page, cookies, security and other types of HAR information that are not used when replaying from HAR. Defaults tofull. -
setRecordHarOmitContent
public BrowserType.LaunchPersistentContextOptions setRecordHarOmitContent(boolean recordHarOmitContent) Optional setting to control whether to omit request content from the HAR. Defaults tofalse. -
setRecordHarPath
Enables HAR recording for all pages into the specified HAR file on the filesystem. If not specified, the HAR is not recorded. Make sure to callBrowserContext.close()for the HAR to be saved. -
setRecordHarUrlFilter
-
setRecordHarUrlFilter
-
setRecordVideoDir
Enables video recording for all pages into the specified directory. If not specified videos are not recorded. Make sure to callBrowserContext.close()for videos to be saved. -
setRecordVideoSize
Dimensions of the recorded videos. If not specified the size will be equal toviewportscaled down to fit into 800x800. Ifviewportis not configured explicitly the video size defaults to 800x450. Actual picture of each page will be scaled down if necessary to fit the specified size. -
setRecordVideoSize
public BrowserType.LaunchPersistentContextOptions setRecordVideoSize(RecordVideoSize recordVideoSize) Dimensions of the recorded videos. If not specified the size will be equal toviewportscaled down to fit into 800x800. Ifviewportis not configured explicitly the video size defaults to 800x450. Actual picture of each page will be scaled down if necessary to fit the specified size. -
setReducedMotion
Emulates"prefers-reduced-motion"media feature, supported values are"reduce","no-preference". SeePage.emulateMedia()for more details. Passingnullresets emulation to system defaults. Defaults to"no-preference". -
setScreenSize
Emulates consistent window screen size available inside web page viawindow.screen. Is only used when theviewportis set. -
setScreenSize
Emulates consistent window screen size available inside web page viawindow.screen. Is only used when theviewportis set. -
setServiceWorkers
public BrowserType.LaunchPersistentContextOptions setServiceWorkers(ServiceWorkerPolicy serviceWorkers) Whether to allow sites to register Service workers. Defaults to"allow".-
"allow": Service Workers can be registered. -
"block": Playwright will block all registration of Service Workers.
-
-
setSlowMo
Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on. -
setStrictSelectors
If set to true, enables strict selectors mode for this context. In the strict selectors mode all operations on selectors that imply single target DOM element will throw when more than one element matches the selector. This option does not affect any Locator APIs (Locators are always strict). Defaults tofalse. SeeLocatorto learn more about the strict mode. -
setTimeout
Maximum time in milliseconds to wait for the browser instance to start. Defaults to30000(30 seconds). Pass0to disable timeout. -
setTimezoneId
Changes the timezone of the context. See ICU's metaZones.txt for a list of supported timezone IDs. Defaults to the system timezone. -
setTracesDir
If specified, traces are saved into this directory. -
setUserAgent
Specific user agent to use in this context. -
setViewportSize
Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Usenullto disable the consistent viewport emulation. Learn more about viewport emulation.NOTE: The
nullvalue opts out from the default presets, makes viewport depend on the host window size defined by the operating system. It makes the execution of the tests non-deterministic. -
setViewportSize
Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Usenullto disable the consistent viewport emulation. Learn more about viewport emulation.NOTE: The
nullvalue opts out from the default presets, makes viewport depend on the host window size defined by the operating system. It makes the execution of the tests non-deterministic.
-