Skip to content

Latest commit

 

History

History
68 lines (50 loc) · 2.21 KB

electron.mdx

File metadata and controls

68 lines (50 loc) · 2.21 KB
title Testing Electron apps
description Test a desktop app built with Electron from a QA Wolf flow.
sidebarTitle Electron apps
Electron flows use `@qawolf/flows/web`. The callback receives the first window as `page`, giving you the full Playwright API for interacting with the app.

Examples

Launch and interact with an Electron app

import { flow } from "@qawolf/flows/web";

export default flow(
  "Sign in to desktop app",
  {
    target: "Electron",
    launch: { executablePath: "/Applications/MyApp.app/Contents/MacOS/MyApp" },
  },
  async ({ page, test }) => {
    await test("sign in", async () => {
      await page.getByRole("button", { name: "Sign in" }).click();
    });
  },
);

Choose the executable path at runtime

Use explicit launch when the path depends on runtime logic — for example, switching between a stable and canary build.

import { flow, launch } from "@qawolf/flows/web";

export default flow("Sign in to desktop app", "Web - Chrome", async () => {
  const useCanary = process.env.USE_CANARY_APP === "true";

  const { firstWindowPage } = await launch({
    kind: "electron",
    executablePath: useCanary
      ? "/Applications/MyApp Canary.app/Contents/MacOS/MyApp"
      : "/Applications/MyApp.app/Contents/MacOS/MyApp",
  });

  await firstWindowPage.getByRole("button", { name: "Sign in" }).click();
});

When to use

  • Your app is a desktop application built with Electron.
  • You need to test app startup, window behavior, or native OS integrations.
  • Your flow needs to interact with the first Electron window before any navigation.
  • You want to switch between builds — stable vs canary — at runtime.

Notes

Declarative vs explicit launch

For most Electron flows, use the declarative style with target: "Electron" and launch.executablePath. The callback receives the first window as page automatically.

Use explicit launch({ kind: "electron", executablePath }) only when the executable path depends on runtime logic. In this case, the first window is returned as firstWindowPage rather than injected as page.

For the full Electron launch shape, see the Web API Reference.