setDownloadBehavior method
Future<void>
setDownloadBehavior(
- @Enum(['deny', 'allow', 'allowAndName', 'default']) String behavior, {
- BrowserContextID? browserContextId,
- String? downloadPath,
- bool? eventsEnabled,
Set the behavior when downloading a file.
behavior
Whether to allow all or deny all download requests, or use default Chrome behavior if
available (otherwise deny). |allowAndName| allows download and names files according to
their dowmload guids.
browserContextId
BrowserContext to set download behavior. When omitted, default browser context is used.
downloadPath
The default path to save downloaded files to. This is required if behavior is set to 'allow'
or 'allowAndName'.
eventsEnabled
Whether to emit download events (defaults to false).
Implementation
Future<void> setDownloadBehavior(
@Enum(['deny', 'allow', 'allowAndName', 'default']) String behavior,
{BrowserContextID? browserContextId,
String? downloadPath,
bool? eventsEnabled}) async {
assert(
const ['deny', 'allow', 'allowAndName', 'default'].contains(behavior));
await _client.send('Browser.setDownloadBehavior', {
'behavior': behavior,
if (browserContextId != null) 'browserContextId': browserContextId,
if (downloadPath != null) 'downloadPath': downloadPath,
if (eventsEnabled != null) 'eventsEnabled': eventsEnabled,
});
}