Class BrowserType.LaunchPersistentContextOptions
- java.lang.Object
-
- com.microsoft.playwright.BrowserType.LaunchPersistentContextOptions
-
- Enclosing interface:
- BrowserType
public static class BrowserType.LaunchPersistentContextOptions extends Object
-
-
Field Summary
Fields Modifier and Type Field Description BooleanacceptDownloadsWhether to automatically download all the attachments.List<String>argsNOTE: Use custom browser args at your own risk, as some of them may break Playwright functionality.StringbaseURLWhen 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.BooleanbypassCSPToggles bypassing page's Content-Security-Policy.ObjectchannelBrowser distribution channel.BooleanchromiumSandboxEnable Chromium sandboxing.Optional<ColorScheme>colorSchemeEmulates"prefers-colors-scheme"media feature, supported values are"light","dark","no-preference".DoubledeviceScaleFactorSpecify device scale factor (can be thought of as dpr).BooleandevtoolsDeprecated.Use debugging tools instead.PathdownloadsPathIf specified, accepted downloads are downloaded into this directory.Map<String,String>envSpecify environment variables that will be visible to the browser.PathexecutablePathPath to a browser executable to run instead of the bundled one.Map<String,String>extraHTTPHeadersAn object containing additional HTTP headers to be sent with every request.Map<String,Object>firefoxUserPrefsFirefox user preferences.Optional<ForcedColors>forcedColorsEmulates"forced-colors"media feature, supported values are"active","none".GeolocationgeolocationBooleanhandleSIGHUPClose the browser process on SIGHUP.BooleanhandleSIGINTClose the browser process on Ctrl-C.BooleanhandleSIGTERMClose the browser process on SIGTERM.BooleanhasTouchSpecifies if viewport supports touch events.BooleanheadlessWhether to run browser in headless mode.HttpCredentialshttpCredentialsCredentials for HTTP authentication.BooleanignoreAllDefaultArgsIftrue, Playwright does not pass its own configurations args and only uses the ones fromargs.List<String>ignoreDefaultArgsIftrue, Playwright does not pass its own configurations args and only uses the ones fromargs.BooleanignoreHTTPSErrorsWhether to ignore HTTPS errors when sending network requests.BooleanisMobileWhether themeta viewporttag is taken into account and touch events are enabled.BooleanjavaScriptEnabledWhether or not to enable JavaScript in the context.StringlocaleSpecify user locale, for exampleen-GB,de-DE, etc.BooleanofflineWhether to emulate network being offline.List<String>permissionsA list of permissions to grant to all pages in this context.ProxyproxyNetwork proxy settings.HarContentPolicyrecordHarContentOptional setting to control resource content management.HarModerecordHarModeWhen set tominimal, only record information necessary for routing from HAR.BooleanrecordHarOmitContentOptional setting to control whether to omit request content from the HAR.PathrecordHarPathEnables HAR recording for all pages into the specified HAR file on the filesystem.ObjectrecordHarUrlFilterPathrecordVideoDirEnables video recording for all pages into the specified directory.RecordVideoSizerecordVideoSizeDimensions of the recorded videos.Optional<ReducedMotion>reducedMotionEmulates"prefers-reduced-motion"media feature, supported values are"reduce","no-preference".ScreenSizescreenSizeEmulates consistent window screen size available inside web page viawindow.screen.ServiceWorkerPolicyserviceWorkersWhether to allow sites to register Service workers.DoubleslowMoSlows down Playwright operations by the specified amount of milliseconds.BooleanstrictSelectorsIf set to true, enables strict selectors mode for this context.DoubletimeoutMaximum time in milliseconds to wait for the browser instance to start.StringtimezoneIdChanges the timezone of the context.PathtracesDirIf specified, traces are saved into this directory.StringuserAgentSpecific user agent to use in this context.Optional<ViewportSize>viewportSizeEmulates consistent viewport for each page.
-
Constructor Summary
Constructors Constructor Description LaunchPersistentContextOptions()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description BrowserType.LaunchPersistentContextOptionssetAcceptDownloads(boolean acceptDownloads)Whether to automatically download all the attachments.BrowserType.LaunchPersistentContextOptionssetArgs(List<String> args)NOTE: Use custom browser args at your own risk, as some of them may break Playwright functionality.BrowserType.LaunchPersistentContextOptionssetBaseURL(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.BrowserType.LaunchPersistentContextOptionssetBypassCSP(boolean bypassCSP)Toggles bypassing page's Content-Security-Policy.BrowserType.LaunchPersistentContextOptionssetChannel(BrowserChannel channel)Deprecated.BrowserType.LaunchPersistentContextOptionssetChannel(String channel)Browser distribution channel.BrowserType.LaunchPersistentContextOptionssetChromiumSandbox(boolean chromiumSandbox)Enable Chromium sandboxing.BrowserType.LaunchPersistentContextOptionssetColorScheme(ColorScheme colorScheme)Emulates"prefers-colors-scheme"media feature, supported values are"light","dark","no-preference".BrowserType.LaunchPersistentContextOptionssetDeviceScaleFactor(double deviceScaleFactor)Specify device scale factor (can be thought of as dpr).BrowserType.LaunchPersistentContextOptionssetDevtools(boolean devtools)Deprecated.Use debugging tools instead.BrowserType.LaunchPersistentContextOptionssetDownloadsPath(Path downloadsPath)If specified, accepted downloads are downloaded into this directory.BrowserType.LaunchPersistentContextOptionssetEnv(Map<String,String> env)Specify environment variables that will be visible to the browser.BrowserType.LaunchPersistentContextOptionssetExecutablePath(Path executablePath)Path to a browser executable to run instead of the bundled one.BrowserType.LaunchPersistentContextOptionssetExtraHTTPHeaders(Map<String,String> extraHTTPHeaders)An object containing additional HTTP headers to be sent with every request.BrowserType.LaunchPersistentContextOptionssetFirefoxUserPrefs(Map<String,Object> firefoxUserPrefs)Firefox user preferences.BrowserType.LaunchPersistentContextOptionssetForcedColors(ForcedColors forcedColors)Emulates"forced-colors"media feature, supported values are"active","none".BrowserType.LaunchPersistentContextOptionssetGeolocation(double latitude, double longitude)BrowserType.LaunchPersistentContextOptionssetGeolocation(Geolocation geolocation)BrowserType.LaunchPersistentContextOptionssetHandleSIGHUP(boolean handleSIGHUP)Close the browser process on SIGHUP.BrowserType.LaunchPersistentContextOptionssetHandleSIGINT(boolean handleSIGINT)Close the browser process on Ctrl-C.BrowserType.LaunchPersistentContextOptionssetHandleSIGTERM(boolean handleSIGTERM)Close the browser process on SIGTERM.BrowserType.LaunchPersistentContextOptionssetHasTouch(boolean hasTouch)Specifies if viewport supports touch events.BrowserType.LaunchPersistentContextOptionssetHeadless(boolean headless)Whether to run browser in headless mode.BrowserType.LaunchPersistentContextOptionssetHttpCredentials(HttpCredentials httpCredentials)Credentials for HTTP authentication.BrowserType.LaunchPersistentContextOptionssetHttpCredentials(String username, String password)Credentials for HTTP authentication.BrowserType.LaunchPersistentContextOptionssetIgnoreAllDefaultArgs(boolean ignoreAllDefaultArgs)Iftrue, Playwright does not pass its own configurations args and only uses the ones fromargs.BrowserType.LaunchPersistentContextOptionssetIgnoreDefaultArgs(List<String> ignoreDefaultArgs)Iftrue, Playwright does not pass its own configurations args and only uses the ones fromargs.BrowserType.LaunchPersistentContextOptionssetIgnoreHTTPSErrors(boolean ignoreHTTPSErrors)Whether to ignore HTTPS errors when sending network requests.BrowserType.LaunchPersistentContextOptionssetIsMobile(boolean isMobile)Whether themeta viewporttag is taken into account and touch events are enabled.BrowserType.LaunchPersistentContextOptionssetJavaScriptEnabled(boolean javaScriptEnabled)Whether or not to enable JavaScript in the context.BrowserType.LaunchPersistentContextOptionssetLocale(String locale)Specify user locale, for exampleen-GB,de-DE, etc.BrowserType.LaunchPersistentContextOptionssetOffline(boolean offline)Whether to emulate network being offline.BrowserType.LaunchPersistentContextOptionssetPermissions(List<String> permissions)A list of permissions to grant to all pages in this context.BrowserType.LaunchPersistentContextOptionssetProxy(Proxy proxy)Network proxy settings.BrowserType.LaunchPersistentContextOptionssetProxy(String server)Network proxy settings.BrowserType.LaunchPersistentContextOptionssetRecordHarContent(HarContentPolicy recordHarContent)Optional setting to control resource content management.BrowserType.LaunchPersistentContextOptionssetRecordHarMode(HarMode recordHarMode)When set tominimal, only record information necessary for routing from HAR.BrowserType.LaunchPersistentContextOptionssetRecordHarOmitContent(boolean recordHarOmitContent)Optional setting to control whether to omit request content from the HAR.BrowserType.LaunchPersistentContextOptionssetRecordHarPath(Path recordHarPath)Enables HAR recording for all pages into the specified HAR file on the filesystem.BrowserType.LaunchPersistentContextOptionssetRecordHarUrlFilter(String recordHarUrlFilter)BrowserType.LaunchPersistentContextOptionssetRecordHarUrlFilter(Pattern recordHarUrlFilter)BrowserType.LaunchPersistentContextOptionssetRecordVideoDir(Path recordVideoDir)Enables video recording for all pages into the specified directory.BrowserType.LaunchPersistentContextOptionssetRecordVideoSize(int width, int height)Dimensions of the recorded videos.BrowserType.LaunchPersistentContextOptionssetRecordVideoSize(RecordVideoSize recordVideoSize)Dimensions of the recorded videos.BrowserType.LaunchPersistentContextOptionssetReducedMotion(ReducedMotion reducedMotion)Emulates"prefers-reduced-motion"media feature, supported values are"reduce","no-preference".BrowserType.LaunchPersistentContextOptionssetScreenSize(int width, int height)Emulates consistent window screen size available inside web page viawindow.screen.BrowserType.LaunchPersistentContextOptionssetScreenSize(ScreenSize screenSize)Emulates consistent window screen size available inside web page viawindow.screen.BrowserType.LaunchPersistentContextOptionssetServiceWorkers(ServiceWorkerPolicy serviceWorkers)Whether to allow sites to register Service workers.BrowserType.LaunchPersistentContextOptionssetSlowMo(double slowMo)Slows down Playwright operations by the specified amount of milliseconds.BrowserType.LaunchPersistentContextOptionssetStrictSelectors(boolean strictSelectors)If set to true, enables strict selectors mode for this context.BrowserType.LaunchPersistentContextOptionssetTimeout(double timeout)Maximum time in milliseconds to wait for the browser instance to start.BrowserType.LaunchPersistentContextOptionssetTimezoneId(String timezoneId)Changes the timezone of the context.BrowserType.LaunchPersistentContextOptionssetTracesDir(Path tracesDir)If specified, traces are saved into this directory.BrowserType.LaunchPersistentContextOptionssetUserAgent(String userAgent)Specific user agent to use in this context.BrowserType.LaunchPersistentContextOptionssetViewportSize(int width, int height)Emulates consistent viewport for each page.BrowserType.LaunchPersistentContextOptionssetViewportSize(ViewportSize viewportSize)Emulates consistent viewport for each page.
-
-
-
Field Detail
-
acceptDownloads
public Boolean acceptDownloads
Whether to automatically download all the attachments. Defaults totruewhere all the downloads are accepted.
-
args
public List<String> args
NOTE: Use custom browser args at your own risk, as some of them may break Playwright functionality.Additional arguments to pass to the browser instance. The list of Chromium flags can be found here.
-
baseURL
public 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. 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
public Boolean bypassCSP
Toggles bypassing page's Content-Security-Policy. Defaults tofalse.
-
channel
public Object 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
public Boolean chromiumSandbox
Enable Chromium sandboxing. Defaults tofalse.
-
colorScheme
public Optional<ColorScheme> 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
public Double deviceScaleFactor
Specify device scale factor (can be thought of as dpr). Defaults to1. Learn more about emulating devices with device scale factor.
-
devtools
public Boolean devtools
Deprecated.Use debugging tools instead.
-
downloadsPath
public Path 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
public Map<String,String> env
Specify environment variables that will be visible to the browser. Defaults toprocess.env.
-
executablePath
public Path 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
public Map<String,String> extraHTTPHeaders
An object containing additional HTTP headers to be sent with every request. Defaults to none.
-
firefoxUserPrefs
public Map<String,Object> firefoxUserPrefs
Firefox user preferences. Learn more about the Firefox user preferences atabout:config.
-
forcedColors
public Optional<ForcedColors> 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
public Geolocation geolocation
-
handleSIGHUP
public Boolean handleSIGHUP
Close the browser process on SIGHUP. Defaults totrue.
-
handleSIGINT
public Boolean handleSIGINT
Close the browser process on Ctrl-C. Defaults totrue.
-
handleSIGTERM
public Boolean handleSIGTERM
Close the browser process on SIGTERM. Defaults totrue.
-
hasTouch
public Boolean hasTouch
Specifies if viewport supports touch events. Defaults to false. Learn more about mobile emulation.
-
headless
public Boolean headless
-
httpCredentials
public HttpCredentials httpCredentials
Credentials for HTTP authentication. If no origin is specified, the username and password are sent to any servers upon unauthorized responses.
-
ignoreAllDefaultArgs
public Boolean ignoreAllDefaultArgs
Iftrue, Playwright does not pass its own configurations args and only uses the ones fromargs. Dangerous option; use with care. Defaults tofalse.
-
ignoreDefaultArgs
public List<String> ignoreDefaultArgs
Iftrue, Playwright does not pass its own configurations args and only uses the ones fromargs. Dangerous option; use with care.
-
ignoreHTTPSErrors
public Boolean ignoreHTTPSErrors
Whether to ignore HTTPS errors when sending network requests. Defaults tofalse.
-
isMobile
public Boolean 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
public Boolean javaScriptEnabled
Whether or not to enable JavaScript in the context. Defaults totrue. Learn more about disabling JavaScript.
-
locale
public String 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
public Boolean offline
Whether to emulate network being offline. Defaults tofalse. Learn more about network emulation.
-
permissions
public List<String> permissions
A list of permissions to grant to all pages in this context. SeeBrowserContext.grantPermissions()for more details. Defaults to none.
-
proxy
public Proxy proxy
Network proxy settings.
-
recordHarContent
public 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.
-
recordHarMode
public HarMode 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
public Boolean recordHarOmitContent
Optional setting to control whether to omit request content from the HAR. Defaults tofalse.
-
recordHarPath
public Path 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
public Object recordHarUrlFilter
-
recordVideoDir
public Path 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
public 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.
-
reducedMotion
public Optional<ReducedMotion> 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
public ScreenSize screenSize
Emulates consistent window screen size available inside web page viawindow.screen. Is only used when theviewportis set.
-
serviceWorkers
public 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.
-
-
slowMo
public Double slowMo
Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on.
-
strictSelectors
public Boolean 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
public Double timeout
Maximum time in milliseconds to wait for the browser instance to start. Defaults to30000(30 seconds). Pass0to disable timeout.
-
timezoneId
public String 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
public Path tracesDir
If specified, traces are saved into this directory.
-
userAgent
public String userAgent
Specific user agent to use in this context.
-
viewportSize
public Optional<ViewportSize> 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.
-
-
Method Detail
-
setAcceptDownloads
public BrowserType.LaunchPersistentContextOptions setAcceptDownloads(boolean acceptDownloads)
Whether to automatically download all the attachments. Defaults totruewhere all the downloads are accepted.
-
setArgs
public BrowserType.LaunchPersistentContextOptions setArgs(List<String> args)
NOTE: Use custom browser args at your own risk, as some of them may break Playwright functionality.Additional arguments to pass to the browser instance. The list of Chromium flags can be found here.
-
setBaseURL
public BrowserType.LaunchPersistentContextOptions 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. 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
public BrowserType.LaunchPersistentContextOptions setBypassCSP(boolean bypassCSP)
Toggles bypassing page's Content-Security-Policy. Defaults tofalse.
-
setChannel
@Deprecated public BrowserType.LaunchPersistentContextOptions setChannel(BrowserChannel channel)
Deprecated.
-
setChannel
public BrowserType.LaunchPersistentContextOptions setChannel(String 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.
-
setChromiumSandbox
public BrowserType.LaunchPersistentContextOptions setChromiumSandbox(boolean chromiumSandbox)
Enable Chromium sandboxing. Defaults tofalse.
-
setColorScheme
public BrowserType.LaunchPersistentContextOptions setColorScheme(ColorScheme 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".
-
setDeviceScaleFactor
public BrowserType.LaunchPersistentContextOptions setDeviceScaleFactor(double deviceScaleFactor)
Specify device scale factor (can be thought of as dpr). Defaults to1. Learn more about emulating devices with device scale factor.
-
setDevtools
public BrowserType.LaunchPersistentContextOptions setDevtools(boolean devtools)
Deprecated.Use debugging tools instead.
-
setDownloadsPath
public BrowserType.LaunchPersistentContextOptions setDownloadsPath(Path 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.
-
setEnv
public BrowserType.LaunchPersistentContextOptions setEnv(Map<String,String> env)
Specify environment variables that will be visible to the browser. Defaults toprocess.env.
-
setExecutablePath
public BrowserType.LaunchPersistentContextOptions setExecutablePath(Path 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.
-
setExtraHTTPHeaders
public BrowserType.LaunchPersistentContextOptions setExtraHTTPHeaders(Map<String,String> extraHTTPHeaders)
An object containing additional HTTP headers to be sent with every request. Defaults to none.
-
setFirefoxUserPrefs
public BrowserType.LaunchPersistentContextOptions setFirefoxUserPrefs(Map<String,Object> firefoxUserPrefs)
Firefox user preferences. Learn more about the Firefox user preferences atabout:config.
-
setForcedColors
public BrowserType.LaunchPersistentContextOptions setForcedColors(ForcedColors forcedColors)
Emulates"forced-colors"media feature, supported values are"active","none". SeePage.emulateMedia()for more details. Passingnullresets emulation to system defaults. Defaults to"none".
-
setGeolocation
public BrowserType.LaunchPersistentContextOptions setGeolocation(double latitude, double longitude)
-
setGeolocation
public BrowserType.LaunchPersistentContextOptions setGeolocation(Geolocation geolocation)
-
setHandleSIGHUP
public BrowserType.LaunchPersistentContextOptions setHandleSIGHUP(boolean handleSIGHUP)
Close the browser process on SIGHUP. Defaults totrue.
-
setHandleSIGINT
public BrowserType.LaunchPersistentContextOptions setHandleSIGINT(boolean handleSIGINT)
Close the browser process on Ctrl-C. Defaults totrue.
-
setHandleSIGTERM
public BrowserType.LaunchPersistentContextOptions setHandleSIGTERM(boolean handleSIGTERM)
Close the browser process on SIGTERM. Defaults totrue.
-
setHasTouch
public BrowserType.LaunchPersistentContextOptions setHasTouch(boolean hasTouch)
Specifies if viewport supports touch events. Defaults to false. Learn more about mobile emulation.
-
setHeadless
public BrowserType.LaunchPersistentContextOptions setHeadless(boolean headless)
-
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
public BrowserType.LaunchPersistentContextOptions setIgnoreHTTPSErrors(boolean ignoreHTTPSErrors)
Whether to ignore HTTPS errors when sending network requests. Defaults tofalse.
-
setIsMobile
public BrowserType.LaunchPersistentContextOptions setIsMobile(boolean 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.
-
setJavaScriptEnabled
public BrowserType.LaunchPersistentContextOptions setJavaScriptEnabled(boolean javaScriptEnabled)
Whether or not to enable JavaScript in the context. Defaults totrue. Learn more about disabling JavaScript.
-
setLocale
public BrowserType.LaunchPersistentContextOptions setLocale(String 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.
-
setOffline
public BrowserType.LaunchPersistentContextOptions setOffline(boolean offline)
Whether to emulate network being offline. Defaults tofalse. Learn more about network emulation.
-
setPermissions
public BrowserType.LaunchPersistentContextOptions setPermissions(List<String> permissions)
A list of permissions to grant to all pages in this context. SeeBrowserContext.grantPermissions()for more details. Defaults to none.
-
setProxy
public BrowserType.LaunchPersistentContextOptions setProxy(String server)
Network proxy settings.
-
setProxy
public BrowserType.LaunchPersistentContextOptions setProxy(Proxy proxy)
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
public BrowserType.LaunchPersistentContextOptions setRecordHarMode(HarMode 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.
-
setRecordHarOmitContent
public BrowserType.LaunchPersistentContextOptions setRecordHarOmitContent(boolean recordHarOmitContent)
Optional setting to control whether to omit request content from the HAR. Defaults tofalse.
-
setRecordHarPath
public BrowserType.LaunchPersistentContextOptions setRecordHarPath(Path 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.
-
setRecordHarUrlFilter
public BrowserType.LaunchPersistentContextOptions setRecordHarUrlFilter(String recordHarUrlFilter)
-
setRecordHarUrlFilter
public BrowserType.LaunchPersistentContextOptions setRecordHarUrlFilter(Pattern recordHarUrlFilter)
-
setRecordVideoDir
public BrowserType.LaunchPersistentContextOptions setRecordVideoDir(Path 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.
-
setRecordVideoSize
public BrowserType.LaunchPersistentContextOptions setRecordVideoSize(int width, int height)
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
public BrowserType.LaunchPersistentContextOptions setReducedMotion(ReducedMotion 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".
-
setScreenSize
public BrowserType.LaunchPersistentContextOptions setScreenSize(int width, int height)
Emulates consistent window screen size available inside web page viawindow.screen. Is only used when theviewportis set.
-
setScreenSize
public BrowserType.LaunchPersistentContextOptions setScreenSize(ScreenSize screenSize)
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
public BrowserType.LaunchPersistentContextOptions setSlowMo(double slowMo)
Slows down Playwright operations by the specified amount of milliseconds. Useful so that you can see what is going on.
-
setStrictSelectors
public BrowserType.LaunchPersistentContextOptions setStrictSelectors(boolean 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.
-
setTimeout
public BrowserType.LaunchPersistentContextOptions setTimeout(double timeout)
Maximum time in milliseconds to wait for the browser instance to start. Defaults to30000(30 seconds). Pass0to disable timeout.
-
setTimezoneId
public BrowserType.LaunchPersistentContextOptions setTimezoneId(String timezoneId)
Changes the timezone of the context. See ICU's metaZones.txt for a list of supported timezone IDs. Defaults to the system timezone.
-
setTracesDir
public BrowserType.LaunchPersistentContextOptions setTracesDir(Path tracesDir)
If specified, traces are saved into this directory.
-
setUserAgent
public BrowserType.LaunchPersistentContextOptions setUserAgent(String userAgent)
Specific user agent to use in this context.
-
setViewportSize
public BrowserType.LaunchPersistentContextOptions setViewportSize(int width, int height)
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
public BrowserType.LaunchPersistentContextOptions setViewportSize(ViewportSize 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.
-
-