Launches electron application specified with the
executablePath.
Optionaloptions: {OptionalacceptDownloads?: booleanWhether to automatically download all the attachments. Defaults to true where all the downloads are accepted.
Optionalargs?: string[]Additional arguments to pass to the application when launching. You typically pass the main script name here.
OptionalartifactsDir?: stringIf specified, artifacts (traces, videos, downloads, HAR files, etc.) are saved into this directory. The directory is not cleaned up when the browser closes. If not specified, a temporary directory is used and cleaned up when the browser closes.
OptionalbypassCSP?: booleanToggles bypassing page's Content-Security-Policy. Defaults to false.
OptionalchromiumSandbox?: booleanEnable Chromium sandboxing. Defaults to false.
OptionalcolorScheme?: "light" | "dark" | "no-preference" | nullEmulates prefers-colors-scheme
media feature, supported values are 'light' and 'dark'. See
page.emulateMedia([options]) for more details.
Passing null resets emulation to system defaults. Defaults to 'light'.
Optionalcwd?: stringCurrent working directory to launch application from.
Optionalenv?: { [key: string]: string }Specifies environment variables that will be visible to Electron. Defaults to process.env.
OptionalexecutablePath?: stringLaunches given Electron application. If not specified, launches the default Electron executable installed in this
package, located at node_modules/.bin/electron.
OptionalextraHTTPHeaders?: { [key: string]: string }An object containing additional HTTP headers to be sent with every request. Defaults to none.
Optionalgeolocation?: { accuracy?: number; latitude: number; longitude: number }Optionalaccuracy?: numberNon-negative accuracy value. Defaults to 0.
Latitude between -90 and 90.
Longitude between -180 and 180.
OptionalhttpCredentials?: {Credentials for HTTP authentication. If no origin is specified, the username and password are sent to any servers upon unauthorized responses.
Optionalorigin?: stringRestrain sending http credentials on specific origin (scheme://host:port).
Optionalsend?: "always" | "unauthorized"This option only applies to the requests sent from corresponding
APIRequestContext and does not affect requests sent from
the browser. 'always' - Authorization header with basic authentication credentials will be sent with the each
API request. 'unauthorized - the credentials are only sent when 401 (Unauthorized) response with
WWW-Authenticate header is received. Defaults to 'unauthorized'.
OptionalignoreHTTPSErrors?: booleanWhether to ignore HTTPS errors when sending network requests. Defaults to false.
Optionallocale?: stringSpecify user locale, for example en-GB, de-DE, etc. Locale will affect navigator.language value,
Accept-Language request header value as well as number and date formatting rules. Defaults to the system default
locale. Learn more about emulation in our emulation guide.
Optionaloffline?: booleanWhether to emulate network being offline. Defaults to false. Learn more about
network emulation.
OptionalrecordHar?: {Enables HAR recording for all pages into recordHar.path file.
If not specified, the HAR is not recorded. Make sure to await
browserContext.close([options]) for
the HAR to be saved.
Optionalcontent?: "embed" | "attach" | "omit"Optional setting to control resource content management. If omit is specified, content is not persisted. If
attach is specified, resources are persisted as separate files or entries in the ZIP archive. If embed is
specified, content is stored inline the HAR file as per HAR specification. Defaults to attach for .zip output
files and to embed for all other file extensions.
Optionalmode?: "full" | "minimal"When set to 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.
OptionalomitContent?: booleanOptional setting to control whether to omit request content from the HAR. Defaults to false. Deprecated, use
content policy instead.
Path on the filesystem to write the HAR file to. If the file name ends with .zip, content: 'attach' is used by
default.
OptionalurlFilter?: string | RegExpOptionalrecordVideo?: {Enables video recording for all pages into recordVideo.dir directory. If not specified videos are not recorded.
Make sure to await
browserContext.close([options]) for
videos to be saved.
Optionaldir?: stringPath to the directory to put videos into. If not specified, the videos will be stored in artifactsDir (see
browserType.launch([options]) options).
OptionalshowActions?: {If specified, enables visual annotations on interacted elements during video recording.
Optionalcursor?: "none" | "pointer"Cursor decoration shown for pointer actions. "pointer" (the default) renders a mouse pointer that animates from
the previous action point to the next one. "none" disables the cursor decoration.
Optionalduration?: numberHow long each annotation is displayed in milliseconds. Defaults to 500.
OptionalfontSize?: numberFont size of the action title in pixels. Defaults to 24.
Optionalposition?: "top-left" | "top" | "top-right" | "bottom-left" | "bottom" | "bottom-right"Position of the action title overlay. Defaults to "top-right".
Optionalsize?: { height: number; width: number }Optional dimensions of the recorded videos. If not specified the size will be equal to 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.
Video frame height.
Video frame width.
Optionaltimeout?: numberMaximum time in milliseconds to wait for the application to start. Defaults to 30000 (30 seconds). Pass 0 to
disable timeout.
OptionaltimezoneId?: stringChanges the timezone of the context. See ICU's metaZones.txt for a list of supported timezone IDs. Defaults to the system timezone.
OptionaltracesDir?: stringIf specified, traces are saved into this directory.
Playwright has experimental support for Electron automation. You can access electron namespace via:
An example of the Electron automation script would be:
Supported Electron versions are:
Known issues:
If you are not able to launch Electron and it will end up in timeouts during launch, try the following:
nodeCliInspect(FuseV1Options.EnableNodeCliInspectArguments) fuse is not set tofalse.Mocking native dialogs:
Playwright does not intercept the native Electron dialog API (
dialog.showOpenDialog,dialog.showSaveDialog,dialog.showMessageBox, etc.) because those calls happen in the Electron main process and go straight to OS APIs. Use electronApplication.evaluate(pageFunction[, arg]) to replace the relevant methods in the main process so tests run deterministically without any OS-level UI:The replacement persists until the application is closed. Synchronous variants (
showOpenDialogSync,showSaveDialogSync,showMessageBoxSync) can be stubbed the same way — just return the value directly instead of aPromise.