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.
|
Optional<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.
|
Optional<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.
|
HarContentPolicy |
recordHarContent
Optional setting to control resource content management.
|
HarMode |
recordHarMode
When set to
minimal , only record information necessary for routing from HAR. |
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.
|
Object |
recordHarUrlFilter |
Path |
recordVideoDir
Enables video recording for all pages into the specified directory.
|
RecordVideoSize |
recordVideoSize
Dimensions of the recorded videos.
|
Optional<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 . |
ServiceWorkerPolicy |
serviceWorkers
Whether to allow sites to register Service workers.
|
String |
storageState
Populates context with given storage state.
|
Path |
storageStatePath
Populates context with given storage state.
|
Boolean |
strictSelectors
If 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 |
---|
NewPageOptions() |
Modifier and Type | Method and Description |
---|---|
Browser.NewPageOptions |
setAcceptDownloads(boolean acceptDownloads)
Whether to automatically download all the attachments.
|
Browser.NewPageOptions |
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.NewPageOptions |
setBypassCSP(boolean bypassCSP)
Toggles bypassing page's Content-Security-Policy.
|
Browser.NewPageOptions |
setColorScheme(ColorScheme colorScheme)
Emulates
"prefers-colors-scheme" media feature, supported values are "light" , "dark" , "no-preference" . |
Browser.NewPageOptions |
setDeviceScaleFactor(double deviceScaleFactor)
Specify device scale factor (can be thought of as dpr).
|
Browser.NewPageOptions |
setExtraHTTPHeaders(Map<String,String> extraHTTPHeaders)
An object containing additional HTTP headers to be sent with every request.
|
Browser.NewPageOptions |
setForcedColors(ForcedColors forcedColors)
Emulates
"forced-colors" media feature, supported values are "active" , "none" . |
Browser.NewPageOptions |
setGeolocation(double latitude,
double longitude) |
Browser.NewPageOptions |
setGeolocation(Geolocation geolocation) |
Browser.NewPageOptions |
setHasTouch(boolean hasTouch)
Specifies if viewport supports touch events.
|
Browser.NewPageOptions |
setHttpCredentials(HttpCredentials httpCredentials)
Credentials for HTTP authentication.
|
Browser.NewPageOptions |
setHttpCredentials(String username,
String password)
Credentials for HTTP authentication.
|
Browser.NewPageOptions |
setIgnoreHTTPSErrors(boolean ignoreHTTPSErrors)
Whether to ignore HTTPS errors when sending network requests.
|
Browser.NewPageOptions |
setIsMobile(boolean isMobile)
Whether the
meta viewport tag is taken into account and touch events are enabled. |
Browser.NewPageOptions |
setJavaScriptEnabled(boolean javaScriptEnabled)
Whether or not to enable JavaScript in the context.
|
Browser.NewPageOptions |
setLocale(String locale)
Specify user locale, for example
en-GB , de-DE , etc. |
Browser.NewPageOptions |
setOffline(boolean offline)
Whether to emulate network being offline.
|
Browser.NewPageOptions |
setPermissions(List<String> permissions)
A list of permissions to grant to all pages in this context.
|
Browser.NewPageOptions |
setProxy(Proxy proxy)
Network proxy settings to use with this context.
|
Browser.NewPageOptions |
setProxy(String server)
Network proxy settings to use with this context.
|
Browser.NewPageOptions |
setRecordHarContent(HarContentPolicy recordHarContent)
Optional setting to control resource content management.
|
Browser.NewPageOptions |
setRecordHarMode(HarMode recordHarMode)
When set to
minimal , only record information necessary for routing from HAR. |
Browser.NewPageOptions |
setRecordHarOmitContent(boolean recordHarOmitContent)
Optional setting to control whether to omit request content from the HAR.
|
Browser.NewPageOptions |
setRecordHarPath(Path recordHarPath)
Enables HAR recording for all pages into the specified HAR
file on the filesystem.
|
Browser.NewPageOptions |
setRecordHarUrlFilter(Pattern recordHarUrlFilter) |
Browser.NewPageOptions |
setRecordHarUrlFilter(String recordHarUrlFilter) |
Browser.NewPageOptions |
setRecordVideoDir(Path recordVideoDir)
Enables video recording for all pages into the specified directory.
|
Browser.NewPageOptions |
setRecordVideoSize(int width,
int height)
Dimensions of the recorded videos.
|
Browser.NewPageOptions |
setRecordVideoSize(RecordVideoSize recordVideoSize)
Dimensions of the recorded videos.
|
Browser.NewPageOptions |
setReducedMotion(ReducedMotion reducedMotion)
Emulates
"prefers-reduced-motion" media feature, supported values are "reduce" , "no-preference" . |
Browser.NewPageOptions |
setScreenSize(int width,
int height)
Emulates consistent window screen size available inside web page via
window.screen . |
Browser.NewPageOptions |
setScreenSize(ScreenSize screenSize)
Emulates consistent window screen size available inside web page via
window.screen . |
Browser.NewPageOptions |
setServiceWorkers(ServiceWorkerPolicy serviceWorkers)
Whether to allow sites to register Service workers.
|
Browser.NewPageOptions |
setStorageState(String storageState)
Populates context with given storage state.
|
Browser.NewPageOptions |
setStorageStatePath(Path storageStatePath)
Populates context with given storage state.
|
Browser.NewPageOptions |
setStrictSelectors(boolean strictSelectors)
If specified, enables strict selectors mode for this context.
|
Browser.NewPageOptions |
setTimezoneId(String timezoneId)
Changes the timezone of the context.
|
Browser.NewPageOptions |
setUserAgent(String userAgent)
Specific user agent to use in this context.
|
Browser.NewPageOptions |
setViewportSize(int width,
int height)
Emulates consistent viewport for each page.
|
Browser.NewPageOptions |
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 Optional<ColorScheme> colorScheme
"prefers-colors-scheme"
media feature, supported values are "light"
, "dark"
, "no-preference"
. See
Page.emulateMedia()
for more details. Passing null
resets emulation to system defaults.
Defaults to "light"
.public Double deviceScaleFactor
1
.public Map<String,String> extraHTTPHeaders
public Optional<ForcedColors> forcedColors
"forced-colors"
media feature, supported values are "active"
, "none"
. See Page.emulateMedia()
for more details. Passing null
resets emulation to system defaults. Defaults to "none"
.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 HarContentPolicy recordHarContent
omit
is specified, content is not persisted. If attach
is specified, resources are persisted as separate files and all of these files are archived along with the HAR file.
Defaults to embed
, which stores content inline the HAR file as per HAR specification.public HarMode recordHarMode
minimal
, 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 to full
.public Boolean recordHarOmitContent
false
.public Path recordHarPath
BrowserContext.close()
for the HAR to be saved.public Object recordHarUrlFilter
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 Optional<ReducedMotion> reducedMotion
"prefers-reduced-motion"
media feature, supported values are "reduce"
, "no-preference"
. See Page.emulateMedia()
for more details. Passing null
resets emulation to system defaults. Defaults to
"no-preference"
.public ScreenSize screenSize
window.screen
. Is only used when the viewport
is set.public ServiceWorkerPolicy serviceWorkers
"allow"
.
"allow"
: Service Workers can be
registered."block"
: Playwright will block all registration of Service Workers.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.NewPageOptions setAcceptDownloads(boolean acceptDownloads)
true
where all the downloads are accepted.public Browser.NewPageOptions 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.NewPageOptions setBypassCSP(boolean bypassCSP)
public Browser.NewPageOptions setColorScheme(ColorScheme colorScheme)
"prefers-colors-scheme"
media feature, supported values are "light"
, "dark"
, "no-preference"
. See
Page.emulateMedia()
for more details. Passing null
resets emulation to system defaults.
Defaults to "light"
.public Browser.NewPageOptions setDeviceScaleFactor(double deviceScaleFactor)
1
.public Browser.NewPageOptions setExtraHTTPHeaders(Map<String,String> extraHTTPHeaders)
public Browser.NewPageOptions setForcedColors(ForcedColors forcedColors)
"forced-colors"
media feature, supported values are "active"
, "none"
. See Page.emulateMedia()
for more details. Passing null
resets emulation to system defaults. Defaults to "none"
.public Browser.NewPageOptions setGeolocation(double latitude, double longitude)
public Browser.NewPageOptions setGeolocation(Geolocation geolocation)
public Browser.NewPageOptions setHasTouch(boolean hasTouch)
public Browser.NewPageOptions setHttpCredentials(String username, String password)
public Browser.NewPageOptions setHttpCredentials(HttpCredentials httpCredentials)
public Browser.NewPageOptions setIgnoreHTTPSErrors(boolean ignoreHTTPSErrors)
false
.public Browser.NewPageOptions setIsMobile(boolean isMobile)
meta viewport
tag is taken into account and touch events are enabled. Defaults to false
. Not supported
in Firefox.public Browser.NewPageOptions setJavaScriptEnabled(boolean javaScriptEnabled)
true
.public Browser.NewPageOptions 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.NewPageOptions setOffline(boolean offline)
false
.public Browser.NewPageOptions setPermissions(List<String> permissions)
BrowserContext.grantPermissions()
for more details.public Browser.NewPageOptions 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.NewPageOptions 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.NewPageOptions setRecordHarContent(HarContentPolicy recordHarContent)
omit
is specified, content is not persisted. If attach
is specified, resources are persisted as separate files and all of these files are archived along with the HAR file.
Defaults to embed
, which stores content inline the HAR file as per HAR specification.public Browser.NewPageOptions setRecordHarMode(HarMode recordHarMode)
minimal
, 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 to full
.public Browser.NewPageOptions setRecordHarOmitContent(boolean recordHarOmitContent)
false
.public Browser.NewPageOptions setRecordHarPath(Path recordHarPath)
BrowserContext.close()
for the HAR to be saved.public Browser.NewPageOptions setRecordHarUrlFilter(String recordHarUrlFilter)
public Browser.NewPageOptions setRecordHarUrlFilter(Pattern recordHarUrlFilter)
public Browser.NewPageOptions setRecordVideoDir(Path recordVideoDir)
BrowserContext.close()
for videos to be saved.public Browser.NewPageOptions 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.NewPageOptions 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.NewPageOptions setReducedMotion(ReducedMotion reducedMotion)
"prefers-reduced-motion"
media feature, supported values are "reduce"
, "no-preference"
. See Page.emulateMedia()
for more details. Passing null
resets emulation to system defaults. Defaults to
"no-preference"
.public Browser.NewPageOptions setScreenSize(int width, int height)
window.screen
. Is only used when the viewport
is set.public Browser.NewPageOptions setScreenSize(ScreenSize screenSize)
window.screen
. Is only used when the viewport
is set.public Browser.NewPageOptions setServiceWorkers(ServiceWorkerPolicy serviceWorkers)
"allow"
.
"allow"
: Service Workers can be
registered."block"
: Playwright will block all registration of Service Workers.public Browser.NewPageOptions setStorageState(String storageState)
BrowserContext.storageState()
.public Browser.NewPageOptions setStorageStatePath(Path storageStatePath)
BrowserContext.storageState()
. Path to the file with saved storage
state.public Browser.NewPageOptions setStrictSelectors(boolean strictSelectors)
Locator
to learn
more about the strict mode.public Browser.NewPageOptions setTimezoneId(String timezoneId)
public Browser.NewPageOptions setUserAgent(String userAgent)
public Browser.NewPageOptions setViewportSize(int width, int height)
null
disables the default viewport.public Browser.NewPageOptions setViewportSize(ViewportSize viewportSize)
null
disables the default viewport.Copyright © 2022. All rights reserved.