Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ The daemon routes `POST /tool/:name` requests through the registry, applies Zod
| `get_context` | Returns the current environment context (`e2e` or `prod`), session status, available capabilities, and whether context switching is allowed. |
| `set_context` | Switches the session environment between `e2e` and `prod` modes. Blocked while a session is active. |
| **Screenshots** | |
| `screenshot` | Captures a screenshot of the current page. Supports naming, full-page capture, scoping to a CSS selector, and optional base64 output. Browser: `frame` captures an iframe, or the `selector` element inside it; a selector that matches no element fails fast with `MM_TARGET_NOT_FOUND`. |
| `screenshot` | Captures a screenshot of the current page. Supports naming, full-page capture, scoping to a CSS selector, and optional base64 output. Browser: `frame` captures an iframe, or the `selector` element inside it; without `timeoutMs`, a selector that matches no element fails after 2s with `MM_TARGET_NOT_FOUND`; with it, the call waits that long for the element to appear. |
| **Contracts** | |
| `seed_contract` | Deploys a single smart contract to the local Anvil chain by name. Requires `ContractSeedingCapability`. |
| `seed_contracts` | Deploys multiple smart contracts in sequence. Returns both successful deployments and individual failures. |
Expand Down Expand Up @@ -656,7 +656,7 @@ mm describe-screen
| `mm reset-viewport` | Browser only. Restores the size the page had before the first `mm set-viewport`. |
| `mm get-text <ref> [--timeout <ms>] [--selector <css>] [--testid <id>] [--within <scope>] [--frame <iframe>]` | Reads the text content of an element. Returns the inner text, target descriptor, and character length. Accepts `--timeout` for the total time budget (default: 15s). Useful for asserting visible values without screenshots. |
| `mm describe-screen [--frame <iframe>]` | Captures the full screen state: extension info, visible test IDs, and a trimmed accessibility tree with deterministic refs (`e1`, `e2`, ...). Visible iframes are listed after the page with refs `f1e1`, `f2e1`, ...; `--frame` lists only that iframe. This is the primary command for understanding what's on screen before interacting. |
| `mm screenshot [--name <name>] [--selector <css>] [--timeout <ms>] [--frame <iframe>]` | Takes a full-page screenshot of the current page. Saves to the artifacts directory. Use `--name` to set a descriptive filename, `--selector` to capture one element, and `--frame` to capture an iframe (with `--selector`, the element inside it). `--selector` waits up to `--timeout` for the element (default: 15s); a selector that matches no element fails fast with `MM_TARGET_NOT_FOUND`. |
| `mm screenshot [--name <name>] [--selector <css>] [--timeout <ms>] [--frame <iframe>]` | Takes a full-page screenshot of the current page. Saves to the artifacts directory. Use `--name` to set a descriptive filename, `--selector` to capture one element, and `--frame` to capture an iframe (with `--selector`, the element inside it). `--selector` waits for the element (default: 15s). Without `--timeout`, a missing element fails after 2s with `MM_TARGET_NOT_FOUND`; with `--timeout`, the command waits that long for it to appear. |
| `mm wait-for <ref> [--timeout <ms>] [--selector <css>] [--testid <id>] [--within <scope>] [--frame <iframe>]` | Blocks until an element identified by its accessibility reference becomes visible, or the timeout expires. Default timeout is 15 seconds. Use `--within` to scope the target inside a parent element. |
| `mm wait-for-notification [--timeout <ms>]` | Waits for the extension notification popup to appear within a timeout. Returns the notification page URL. |
| `mm clipboard <read\|write> [text]` | Reads from or writes to the system clipboard via Chrome DevTools Protocol. Useful for pasting seed phrases or copying addresses. |
Expand Down
2 changes: 1 addition & 1 deletion SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ Captures a screenshot of the current page.
mm screenshot [--name <name>] [--selector <css>] [--timeout <ms>] [--frame <iframe>]
```

`--selector` captures one element and waits up to `--timeout` for it (default: 15s); a selector that matches no element fails fast with `MM_TARGET_NOT_FOUND`. `--frame` (browser) captures an iframe, or with `--selector` the element inside it.
`--selector` captures one element and waits for it to become visible (default: 15s). `--frame` (browser) captures an iframe, or with `--selector` the element inside it. Without `--timeout`, a selector or frame that matches no element fails after 2s with `MM_TARGET_NOT_FOUND`; with `--timeout`, the command waits that long for it to appear, so pass one when the screen is still loading.

Returns: file path, dimensions.

Expand Down
10 changes: 5 additions & 5 deletions src/platform/playwright-driver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ describe('PlaywrightPlatformDriver', () => {
});
});

it('waits for the selector with the given budget before capturing', async () => {
it('waits the given timeout for the selector to appear before capturing', async () => {
const page = createMockPage();
const sessionManager = createMockSessionManager({ hasActive: true });
const wait = vi
Expand All @@ -883,22 +883,22 @@ describe('PlaywrightPlatformDriver', () => {
await driver.screenshot({
name: 'element',
selector: '.modal',
timeoutMs: 2000,
timeoutMs: 10000,
});

expect(wait).toHaveBeenCalledWith(
page,
'selector',
'.modal',
expect.any(Map),
2000,
10000,
undefined,
{ missingTargetWaitMs: MISSING_TARGET_WAIT_MS },
{ missingTargetWaitMs: 10000 },
);
expect(sessionManager.screenshot).toHaveBeenCalledOnce();
});

it('defaults the selector budget to the interaction timeout', async () => {
it('defaults the selector budget to the interaction timeout and fails fast on a missing selector', async () => {
const wait = vi
.spyOn(discoveryModule, 'waitForTarget')
.mockResolvedValue(createMockLocator() as any);
Expand Down
2 changes: 1 addition & 1 deletion src/platform/playwright-driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ export class PlaywrightPlatformDriver implements IPlatformDriver {
new Map(),
options.timeoutMs ?? DEFAULT_INTERACTION_TIMEOUT_MS,
undefined,
{ missingTargetWaitMs: MISSING_TARGET_WAIT_MS },
{ missingTargetWaitMs: options.timeoutMs ?? MISSING_TARGET_WAIT_MS },
);
}
return this.#sessionManager.screenshot({
Expand Down
5 changes: 4 additions & 1 deletion src/platform/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ export type PlatformScreenshotOptions = {
fullPage?: boolean;
selector?: string;
includeBase64?: boolean;
/** Browser: how long to wait for `selector`, in ms. */
/**
* Browser: how long to wait for `selector` to appear, in ms. Without it, a
* selector that matches nothing fails after `MISSING_TARGET_WAIT_MS`.
*/
timeoutMs?: number;
};

Expand Down
Loading
Loading