BrowserContextBuilder
Playwright\Browser\BrowserContextBuilder
Fluent helper to build BrowserContext options arrays. This class does not change any runtime behavior. It only helps produce the associative array expected by Browser::newContext([...]) and Playwright::chromium(['context' => [...]]).
Methods
create()
selffunction create(): self
withViewport()
selffunction withViewport(int $width, int $height): self
withUserAgent()
selffunction withUserAgent(string $userAgent): self
withLocale()
selffunction withLocale(string $locale): self
withTimezoneId()
selffunction withTimezoneId(string $timezoneId): self
withStorageState()
selffunction withStorageState(array|string $state): self
withDownloadsPath()
selffunction withDownloadsPath(string $path): self
withRecordVideoDir()
selffunction withRecordVideoDir(string $dir): self
withColorScheme()
selffunction withColorScheme(string $scheme): self
withDeviceScaleFactor()
selffunction withDeviceScaleFactor(int|float $factor): self
withIsMobile()
selffunction withIsMobile(bool $isMobile = true): self
withHasTouch()
selffunction withHasTouch(bool $hasTouch = true): self
withPermissions()
selffunction withPermissions(array $permissions): self
toArray()
arrayExport as array suitable for Browser::newContext([...]).
function toArray(): array