Repository navigation
docs(core): drive a Mac app with @e2e-dev/core and desktop() (GTM-1179) #2499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
23e79ef
4d1e798
491ddb1
93f05b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { launch } from '@e2e-dev/core'; | ||
| import { desktop } from '@e2e-dev/desktop/engine'; | ||
|
|
||
| await using myApp = await launch(desktop(), { app: { appPath: 'build/MyApp.app' } }); | ||
| await using session = await myApp.newSession(); | ||
| await session.app.open(); | ||
| await session.screen.getByRole('textbox', 'Username').fill('ada'); | ||
| await session.screen.getByRole('button', 'Sign in').tap(); | ||
| const windows = await session.desktop.windows(); | ||
| console.log(await Promise.all(windows.map((window) => window.title()))); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| --- | ||
| title: "@e2e-dev/core" | ||
| description: "API reference for @e2e-dev/core, with launch, hosts, sessions, saved state, and createAgent, for a program that drives a browser or a device without the test runner." | ||
| description: "API reference for @e2e-dev/core, with launch, hosts, sessions, saved state, and createAgent, for a program that drives a browser, a device, or a Mac app without the test runner." | ||
| --- | ||
|
|
||
| `@e2e-dev/core` is the API of a program that drives a browser or a device | ||
| with no test runner around it. `launch` returns a host, a host opens | ||
| sessions, and `createAgent` puts an agent over a session. The | ||
| `@e2e-dev/core` is the API of a program that drives a browser, a device, | ||
| or a Mac app with no test runner around it. `launch` returns a host, a host | ||
| opens sessions, and `createAgent` puts an agent over a session. The | ||
| [guide](/core) shows each of them in use. | ||
|
|
||
| ```ts title="prices.ts" | ||
|
|
@@ -68,7 +68,8 @@ const shop = await launch(web(), { | |
|
|
||
| - `secrets`: values by name, 6 characters or more each. See | ||
| [Pass secrets](/core#pass-secrets). | ||
| - `headed`: shows the browser window. A device ignores it. | ||
| - `headed`: shows the browser window, or brings a desktop app to the front | ||
| when it opens. A device ignores it. | ||
| - `signal`: cancels the launch, and every session and operation on the host. | ||
| - `handleSignals`: closes the host on SIGINT, SIGTERM, and SIGHUP, then lets | ||
| the signal end the program, unless the program listens for it itself. | ||
|
|
@@ -82,24 +83,24 @@ const shop = await launch(web(), { | |
| | Throws | When | | ||
| | --- | --- | | ||
| | `INVALID_ARGUMENT` | The first argument is not an engine, or an option or `app` key is unknown. | | ||
| | `INVALID_CONFIG` | The engine refuses the app: `web()` without `app.url`, `mobile()` without `app.bundleId` or `app.appPath`. | | ||
| | `INVALID_CONFIG` | The engine refuses the app: `web()` without `app.url`, `mobile()` or `desktop()` without `app.bundleId` or `app.appPath`, `desktop()` with `app.url`, `app.permissions`, or an `app.appPath` that isn't a `.app` bundle. | | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3 · Non-blocking · INVALID_CONFIG covers only an appPath without the .app suffix Optional. This does not block the merge. This row says that Run on the base and on this head: |
||
| | `WORKER_PROTOCOL` | Another host owns this engine instance. Call the factory again: `launch(web())`. | | ||
|
|
||
| <a id="app" /> | ||
|
|
||
| ##### `app` | ||
|
|
||
| What `app.open()` opens on a browser, or launches on a device. | ||
| What `app.open()` opens on a browser, or launches on a device or a Mac. | ||
|
|
||
| | Field | For | Meaning | | ||
| | --- | --- | --- | | ||
| | `url` | `web()` | The app's URL. `app.open(path)` resolves against it. | | ||
| | `bundleId` | `mobile()` | The installed app to launch. | | ||
| | `appPath` | `mobile()` | The app build the program runs against, a `.app` or an `.apk`. See [config](/reference/config#apppath). | | ||
| | `bundleId` | `mobile()`, `desktop()` | The installed app to launch. | | ||
| | `appPath` | `mobile()`, `desktop()` | The app build the program runs against, a `.app` or an `.apk` (`desktop()` takes a `.app` only). See [config](/reference/config#apppath). | | ||
| | `linkBase` | `mobile()` | What `app.open(path)` joins the path to and opens as a link. See [config](/reference/config#linkbase). | | ||
| | `identity` | both | The app's name for saved states and recordings. Default: for an HTTP(S) `url`, its origin and base path; for a `file:` `url`, the file's URL; with no `url`, `bundleId`, else `appPath`. See [config](/reference/config#identity). | | ||
| | `launchArguments` | `mobile()` | Arguments the app launches with, a list or an object. See [config](/reference/config#launcharguments). | | ||
| | `permissions` | both | Permissions to grant or deny, or `'all'` to grant every one the engine can. See [config](/reference/config#permissions). | | ||
| | `identity` | all | The app's name for saved states and recordings. Default: for an HTTP(S) `url`, its origin and base path; for a `file:` `url`, the file's URL; with no `url`, `bundleId`, else `appPath`. See [config](/reference/config#identity). | | ||
| | `launchArguments` | `mobile()`, `desktop()` | Arguments the app launches with, a list or an object. See [config](/reference/config#launcharguments). | | ||
| | `permissions` | `web()`, `mobile()` | Permissions to grant or deny, or `'all'` to grant every one the engine can. See [config](/reference/config#permissions). | | ||
|
|
||
| <a id="timeout" /> | ||
|
|
||
|
|
@@ -170,6 +171,7 @@ is also disposable: `await using` closes it. A cleanup that fails throws an | |
| | `platform` | `string` | | ||
| | `browser` | [`Browser`](/reference/web), with `web()` | | ||
| | `device` | [`Device`](/reference/mobile), with `mobile()` | | ||
| | `desktop` | [`Desktop`](/reference/desktop), with `desktop()` | | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3 · Non-blocking · Other text on these pages still describes only web and mobile Optional. This does not block the merge. This row adds
|
||
| | [`saveState`](#savestate) | `Promise<SessionState>` | | ||
| | [`setDefaultTimeout`](#setdefaulttimeout) | `void` | | ||
| | `close` | `Promise<void>` | | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3 · Non-blocking · The Note asks for more than a core script needs
Optional. This does not block the merge.
initrefuses to start only when Accessibility is missing (packages/desktop/src/surface.ts:280). Filling fields, tapping, and reading windows work without Screen Recording, which is for screenshots.docs/desktop.mdx:40-41says "Screen Recording, for screenshots", and this Note does not keep that qualifier.e2e doctorcheck on the linked page loads a runner config. In a core project withoute2e.config.*, it stops withCONFIG_NOT_FOUNDbefore it checks the desktop permissions (run on the base and on this head).