Modifier and Type | Field and Description |
---|---|
Boolean |
acceptDownloads
Whether to automatically download all the attachments.
|
String |
baseURL
When using
Page.navigate() , Page.route() , Page.waitForURL() , Page.waitForRequest() , or Page.waitForResponse() it takes the base URL in consideration by using the URL() constructor for building the corresponding
URL. |
Boolean |
bypassCSP
Toggles bypassing page's Content-Security-Policy.
|
ColorScheme |
colorScheme
Emulates
"prefers-colors-scheme" media feature, supported values are "light" , "dark" , "no-preference" . |
Double |
deviceScaleFactor
Specify device scale factor (can be thought of as dpr).
|
Map<String,String> |
extraHTTPHeaders
An object containing additional HTTP headers to be sent with every request.
|
ForcedColors |
forcedColors
Emulates
"forced-colors" media feature, supported values are "active" , "none" . |
Geolocation |
geolocation |
Boolean |
hasTouch
Specifies if viewport supports touch events.
|
HttpCredentials |
httpCredentials
Credentials for HTTP authentication.
|
Boolean |
ignoreHTTPSErrors
Whether to ignore HTTPS errors when sending network requests.
|
Boolean |
isMobile
Whether the
meta viewport tag is taken into account and touch events are enabled. |
Boolean |
javaScriptEnabled
Whether or not to enable JavaScript in the context.
|
String |
locale
Specify user locale, for example
en-GB , de-DE , etc. |
Boolean |
offline
Whether to emulate network being offline.
|
List<String> |
permissions
A list of permissions to grant to all pages in this context.
|
Proxy |
proxy
Network proxy settings to use with this context.
|
Boolean |
recordHarOmitContent
Optional setting to control whether to omit request content from the HAR.
|
Path |
recordHarPath
Enables HAR recording for all pages into the specified HAR
file on the filesystem.
|
Path |
recordVideoDir
Enables video recording for all pages into the specified directory.
|
RecordVideoSize |
recordVideoSize
Dimensions of the recorded videos.
|
ReducedMotion |
reducedMotion
Emulates
"prefers-reduced-motion" media feature, supported values are "reduce" , "no-preference" . |
ScreenSize |
screenSize
Emulates consistent window screen size available inside web page via
window.screen . |
String |
storageState
Populates context with given storage state.
|
Path |
storageStatePath
Populates context with given storage state.
|
Boolean |
strictSelectors
It specified, enables strict selectors mode for this context.
|
String |
timezoneId
Changes the timezone of the context.
|
String |
userAgent
Specific user agent to use in this context.
|
Optional<ViewportSize> |
viewportSize
Emulates consistent viewport for each page.
|
Constructor and Description |
---|
NewContextOptions() |
Modifier and Type | Method and Description |
---|---|
Browser.NewContextOptions |
setAcceptDownloads(boolean acceptDownloads)
Whether to automatically download all the attachments.
|
Browser.NewContextOptions |
setBaseURL(String baseURL)
When using
Page.navigate() , Page.route() , Page.waitForURL() , Page.waitForRequest() , or Page.waitForResponse() it takes the base URL in consideration by using the URL() constructor for building the corresponding
URL. |
Browser.NewContextOptions |
setBypassCSP(boolean bypassCSP)
Toggles bypassing page's Content-Security-Policy.
|
Browser.NewContextOptions |
setColorScheme(ColorScheme colorScheme)
Emulates
"prefers-colors-scheme" media feature, supported values are "light" , "dark" , "no-preference" . |
Browser.NewContextOptions |
setDeviceScaleFactor(double deviceScaleFactor)
Specify device scale factor (can be thought of as dpr).
|
Browser.NewContextOptions |
setExtraHTTPHeaders(Map<String,String> extraHTTPHeaders)
An object containing additional HTTP headers to be sent with every request.
|
Browser.NewContextOptions |
setForcedColors(ForcedColors forcedColors)
Emulates
"forced-colors" media feature, supported values are "active" , "none" . |
Browser.NewContextOptions |
setGeolocation(double latitude,
double longitude) |
Browser.NewContextOptions |
setGeolocation(Geolocation geolocation) |
Browser.NewContextOptions |
setHasTouch(boolean hasTouch)
Specifies if viewport supports touch events.
|
Browser.NewContextOptions |
setHttpCredentials(HttpCredentials httpCredentials)
Credentials for HTTP authentication.
|
Browser.NewContextOptions |
setHttpCredentials(String username,
String password)
Credentials for HTTP authentication.
|
Browser.NewContextOptions |
setIgnoreHTTPSErrors(boolean ignoreHTTPSErrors)
Whether to ignore HTTPS errors when sending network requests.
|
Browser.NewContextOptions |
setIsMobile(boolean isMobile)
Whether the
meta viewport tag is taken into account and touch events are enabled. |
Browser.NewContextOptions |
setJavaScriptEnabled(boolean javaScriptEnabled)
Whether or not to enable JavaScript in the context.
|
Browser.NewContextOptions |
setLocale(String locale)
Specify user locale, for example
en-GB , de-DE , etc. |
Browser.NewContextOptions |
setOffline(boolean offline)
Whether to emulate network being offline.
|
Browser.NewContextOptions |
setPermissions(List<String> permissions)
A list of permissions to grant to all pages in this context.
|
Browser.NewContextOptions |
setProxy(Proxy proxy)
Network proxy settings to use with this context.
|
Browser.NewContextOptions |
setProxy(String server)
Network proxy settings to use with this context.
|
Browser.NewContextOptions |
setRecordHarOmitContent(boolean recordHarOmitContent)
Optional setting to control whether to omit request content from the HAR.
|
Browser.NewContextOptions |
setRecordHarPath(Path recordHarPath)
Enables HAR recording for all pages into the specified HAR
file on the filesystem.
|
Browser.NewContextOptions |
setRecordVideoDir(Path recordVideoDir)
Enables video recording for all pages into the specified directory.
|
Browser.NewContextOptions |
setRecordVideoSize(int width,
int height)
Dimensions of the recorded videos.
|
Browser.NewContextOptions |
setRecordVideoSize(RecordVideoSize recordVideoSize)
Dimensions of the recorded videos.
|
Browser.NewContextOptions |
setReducedMotion(ReducedMotion reducedMotion)
Emulates
"prefers-reduced-motion" media feature, supported values are "reduce" , "no-preference" . |
Browser.NewContextOptions |
setScreenSize(int width,
int height)
Emulates consistent window screen size available inside web page via
window.screen . |
Browser.NewContextOptions |
setScreenSize(ScreenSize screenSize)
Emulates consistent window screen size available inside web page via
window.screen . |
Browser.NewContextOptions |
setStorageState(String storageState)
Populates context with given storage state.
|
Browser.NewContextOptions |
setStorageStatePath(Path storageStatePath)
Populates context with given storage state.
|
Browser.NewContextOptions |
setStrictSelectors(boolean strictSelectors)
It specified, enables strict selectors mode for this context.
|
Browser.NewContextOptions |
setTimezoneId(String timezoneId)
Changes the timezone of the context.
|
Browser.NewContextOptions |
setUserAgent(String userAgent)
Specific user agent to use in this context.
|
Browser.NewContextOptions |
setViewportSize(int width,
int height)
Emulates consistent viewport for each page.
|
Browser.NewContextOptions |
setViewportSize(ViewportSize viewportSize)
Emulates consistent viewport for each page.
|
public Boolean acceptDownloads
true
where all the downloads are accepted.public String baseURL
Page.navigate()
, Page.route()
, Page.waitForURL()
, Page.waitForRequest()
, or Page.waitForResponse()
it takes the base URL in consideration by using the URL()
constructor for building the corresponding
URL. Examples:
http://localhost:3000
and navigating to /bar.html
results in http://localhost:3000/bar.html
http://localhost:3000/foo/
and navigating to ./bar.html
results in http://localhost:3000/foo/bar.html
http://localhost:3000/foo
(without trailing slash) and navigating to ./bar.html
results in
http://localhost:3000/bar.html
public Boolean bypassCSP
public ColorScheme colorScheme
"prefers-colors-scheme"
media feature, supported values are "light"
, "dark"
, "no-preference"
. See
Page.emulateMedia()
for more details. Defaults to "light"
.public Double deviceScaleFactor
1
.public Map<String,String> extraHTTPHeaders
public ForcedColors forcedColors
"forced-colors"
media feature, supported values are "active"
, "none"
. See Page.emulateMedia()
for more details. Defaults to "none"
.
NOTE: It's not supported in WebKit, see here in their issue tracker.
public Geolocation geolocation
public Boolean hasTouch
public HttpCredentials httpCredentials
public Boolean ignoreHTTPSErrors
false
.public Boolean isMobile
meta viewport
tag is taken into account and touch events are enabled. Defaults to false
. Not supported
in Firefox.public Boolean javaScriptEnabled
true
.public String locale
en-GB
, de-DE
, etc. Locale will affect navigator.language
value, Accept-Language
request header value as well as number and date formatting rules.public Boolean offline
false
.public List<String> permissions
BrowserContext.grantPermissions()
for more details.public Proxy proxy
NOTE: For Chromium on Windows the browser needs to be launched with the global proxy for this option to work. If all contexts
override the proxy, global proxy will be never used and can be any string, for example launch({ proxy: { server:
'http://per-context' } })
.
public Boolean recordHarOmitContent
false
.public Path recordHarPath
BrowserContext.close()
for the HAR to be saved.public Path recordVideoDir
BrowserContext.close()
for videos to be saved.public RecordVideoSize recordVideoSize
viewport
scaled down to fit into
800x800. If viewport
is 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.public ReducedMotion reducedMotion
"prefers-reduced-motion"
media feature, supported values are "reduce"
, "no-preference"
. See Page.emulateMedia()
for more details. Defaults to "no-preference"
.public ScreenSize screenSize
window.screen
. Is only used when the viewport
is set.public String storageState
BrowserContext.storageState()
.public Path storageStatePath
BrowserContext.storageState()
. Path to the file with saved storage
state.public Boolean strictSelectors
Locator
to learn
more about the strict mode.public String timezoneId
public String userAgent
public Optional<ViewportSize> viewportSize
null
disables the default viewport.public Browser.NewContextOptions setAcceptDownloads(boolean acceptDownloads)
true
where all the downloads are accepted.public Browser.NewContextOptions setBaseURL(String baseURL)
Page.navigate()
, Page.route()
, Page.waitForURL()
, Page.waitForRequest()
, or Page.waitForResponse()
it takes the base URL in consideration by using the URL()
constructor for building the corresponding
URL. Examples:
http://localhost:3000
and navigating to /bar.html
results in http://localhost:3000/bar.html
http://localhost:3000/foo/
and navigating to ./bar.html
results in http://localhost:3000/foo/bar.html
http://localhost:3000/foo
(without trailing slash) and navigating to ./bar.html
results in
http://localhost:3000/bar.html
public Browser.NewContextOptions setBypassCSP(boolean bypassCSP)
public Browser.NewContextOptions setColorScheme(ColorScheme colorScheme)
"prefers-colors-scheme"
media feature, supported values are "light"
, "dark"
, "no-preference"
. See
Page.emulateMedia()
for more details. Defaults to "light"
.public Browser.NewContextOptions setDeviceScaleFactor(double deviceScaleFactor)
1
.public Browser.NewContextOptions setExtraHTTPHeaders(Map<String,String> extraHTTPHeaders)
public Browser.NewContextOptions setForcedColors(ForcedColors forcedColors)
"forced-colors"
media feature, supported values are "active"
, "none"
. See Page.emulateMedia()
for more details. Defaults to "none"
.
NOTE: It's not supported in WebKit, see here in their issue tracker.
public Browser.NewContextOptions setGeolocation(double latitude, double longitude)
public Browser.NewContextOptions setGeolocation(Geolocation geolocation)
public Browser.NewContextOptions setHasTouch(boolean hasTouch)
public Browser.NewContextOptions setHttpCredentials(String username, String password)
public Browser.NewContextOptions setHttpCredentials(HttpCredentials httpCredentials)
public Browser.NewContextOptions setIgnoreHTTPSErrors(boolean ignoreHTTPSErrors)
false
.public Browser.NewContextOptions setIsMobile(boolean isMobile)
meta viewport
tag is taken into account and touch events are enabled. Defaults to false
. Not supported
in Firefox.public Browser.NewContextOptions setJavaScriptEnabled(boolean javaScriptEnabled)
true
.public Browser.NewContextOptions setLocale(String locale)
en-GB
, de-DE
, etc. Locale will affect navigator.language
value, Accept-Language
request header value as well as number and date formatting rules.public Browser.NewContextOptions setOffline(boolean offline)
false
.public Browser.NewContextOptions setPermissions(List<String> permissions)
BrowserContext.grantPermissions()
for more details.public Browser.NewContextOptions setProxy(String server)
NOTE: For Chromium on Windows the browser needs to be launched with the global proxy for this option to work. If all contexts
override the proxy, global proxy will be never used and can be any string, for example launch({ proxy: { server:
'http://per-context' } })
.
public Browser.NewContextOptions setProxy(Proxy proxy)
NOTE: For Chromium on Windows the browser needs to be launched with the global proxy for this option to work. If all contexts
override the proxy, global proxy will be never used and can be any string, for example launch({ proxy: { server:
'http://per-context' } })
.
public Browser.NewContextOptions setRecordHarOmitContent(boolean recordHarOmitContent)
false
.public Browser.NewContextOptions setRecordHarPath(Path recordHarPath)
BrowserContext.close()
for the HAR to be saved.public Browser.NewContextOptions setRecordVideoDir(Path recordVideoDir)
BrowserContext.close()
for videos to be saved.public Browser.NewContextOptions setRecordVideoSize(int width, int height)
viewport
scaled down to fit into
800x800. If viewport
is 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.public Browser.NewContextOptions setRecordVideoSize(RecordVideoSize recordVideoSize)
viewport
scaled down to fit into
800x800. If viewport
is 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.public Browser.NewContextOptions setReducedMotion(ReducedMotion reducedMotion)
"prefers-reduced-motion"
media feature, supported values are "reduce"
, "no-preference"
. See Page.emulateMedia()
for more details. Defaults to "no-preference"
.public Browser.NewContextOptions setScreenSize(int width, int height)
window.screen
. Is only used when the viewport
is set.public Browser.NewContextOptions setScreenSize(ScreenSize screenSize)
window.screen
. Is only used when the viewport
is set.public Browser.NewContextOptions setStorageState(String storageState)
BrowserContext.storageState()
.public Browser.NewContextOptions setStorageStatePath(Path storageStatePath)
BrowserContext.storageState()
. Path to the file with saved storage
state.public Browser.NewContextOptions setStrictSelectors(boolean strictSelectors)
Locator
to learn
more about the strict mode.public Browser.NewContextOptions setTimezoneId(String timezoneId)
public Browser.NewContextOptions setUserAgent(String userAgent)
public Browser.NewContextOptions setViewportSize(int width, int height)
null
disables the default viewport.public Browser.NewContextOptions setViewportSize(ViewportSize viewportSize)
null
disables the default viewport.Copyright © 2022. All rights reserved.