Repository navigation
motus-v1.0.15
Motus can now drive a browser it did not start, reach into frames the browser renders in their own process, split a suite across CI agents and merge the results back together, and tell a flaky test from a broken one. Alongside those: an on-screen cursor so screenshots and recordings show where the pointer actually went, automatic recovery when a browser dies mid-run, a pinned-browser workflow for reproducible CI, and IntelliSense documentation in every package. Six behavior changes are called out below; each would otherwise read as a regression.
Attaching and frames
- Attach to a running browser -
MotusLauncher.ConnectAsynctakes either the CDP WebSocket URL or the HTTP debugging endpoint (http://127.0.0.1:9222) and adopts what is already open, sobrowser.Contextsandcontext.Pagesare populated when it returns, with no further call. Targets that appear or disappear afterwards are tracked, so a long-lived session stays accurate instead of describing a snapshot.ConnectOptionscarriesAdoptExistingTargets,SlowMo, and aTimeoutthat bounds the whole connect, because an endpoint that accepts a connection and then answers nothing would otherwise hold the caller for good. This makes a signed-in profile, a warm browser reused between runs, a browser shared with the person sitting in front of it, and a Chromium-based desktop application all drivable. - Ownership is real and observable -
IBrowser.OwnsProcessreports whether Motus started the browser, andDisconnectAsyncends a connection without ever ending a process, including for a browser Motus did start. Adopted contexts are never disposed in the browser, and adopted pages are released rather than closed, so windows belonging to whoever was using the browser survive. - Frames the browser renders in their own process - A cross-origin frame is now in
page.Framesand in its parent'sChildFrames, with the right parent and children, and a frame nested inside one is reachable too: auto-attach is armed recursively, so nesting depth is not a limit. Locators, clicks, evaluation, navigation, and script injection all route to the session that owns the frame. None of this is visible in the API; an out-of-process frame is an ordinaryIFrame. - Execution worlds -
IFrame.EvaluateAsyncgains an overload takingEvaluateOptions { World = ExecutionWorld.Isolated }, which runs against the frame's document without seeing or disturbing the page's globals. Useful in a page whose scripts have replaced built-ins. The main world stays the default, since reading application state is the common case and an isolated world is exactly where that state is not visible. - Frame lifecycle events -
IPagegainsFrameAttached,FrameNavigated, andFrameDetached, andIFramegainsIsDetached, so a held frame handle answers rather than failing obscurely three calls later. - MCP: drive a browser that is already running -
motus mcp --connect <endpoint>starts the server attached, and the newbrowser_attachtool attaches at any point during a session, which is what to use when the endpoint is not known at the time the MCP client is configured.browser_statusreports which browser is being driven and whether the server started it. An attached session adopts the browser's existing context rather than opening one beside it, and leaves the browser running on shutdown. - MCP: look inside frames -
frame_listandframe_selectscope the session to one frame, the same waytab_selectandcontext_selectwork, so a frame is addressable state rather than an argument repeated on every call. Scope coverssnapshot,evaluate, and thewait_fortext conditions; every interaction tool follows through the refs a scoped snapshot hands out. A page snapshot now says how many frames its tree does not describe, so an agent that finds an empty-lookingiframeis pointed atframe_listrather than concluding the content is missing.
Running suites at scale
- Sharding across agents -
motus run --shard <index>/<total>runs a deterministic slice of the suite, 1-based, so a suite splits across CI agents without any agent needing to know what the others took.motus shard merge <files> --output junit:<path>reads the per-shard JUnit and TRX results back and writes one aggregate report, summing the buckets and validating that every shard reported; repeat--outputfor more than one format.--expect <n>makes a missing shard an error rather than a quietly smaller total, which is the failure worth catching: a shard that never ran otherwise looks like a suite that passed. Shard coordinates are stamped into the reports and flow throughTestSuiteInfo. - Flaky tests and quarantine -
--retriesand--retry-policydistinguish a retry for a transient fault from a retry that is hunting flakiness:transient, the default, re-runs only CDP disconnects, whileflakere-runs any failure and marks a test that then passes as flaky rather than green.--fail-on-flakydecides whether that gates the run; by default a flaky test passes it with a warning. Quarantine keeps a known-bad test running and reported while stopping it from failing the build, which is the alternative to deleting it and forgetting it:[Quarantine]marks a test or class in code, and--quarantine <file>takes a list of fully qualified names instead, for quarantining without touching the source.--flaky-history <file>accumulates per-test run, failure, and flake counts into a JSON file across runs, merging with what is already there and tolerating a corrupt one, so flakiness can be seen as a trend instead of a single bad morning. Console, HTML, JUnit and TRX reporters all surface flaky and quarantined status. - MSTest retries a test that lost its browser -
[MotusTestClass]and[MotusTestMethod]re-run a test when the browser disconnects underneath it, while leaving assertion failures strictly alone. A browser dying is not a test result, and before this it was reported as one.
Surviving a browser that dies
- Automatic recovery - A crashed or unhealthy browser is detected, disposed, and replaced with a fresh one rather than poisoning every test after it. Pages cached against the dead browser are invalidated by a generation counter, so a stale handle resolves against the replacement instead of failing.
- Browser output no longer blocks the browser - Redirected stdout and stderr are drained continuously, so a pipe nobody reads can no longer fill and wedge the browser. The retained tail is attached to timeout messages, which turns "the endpoint never answered" into a message that says why.
- Shutdown is bounded and does not race - Closing waits and then kills, disposal cannot double-close, fixture handover is bounded by a timeout, and contexts created during a failed attempt are closed rather than leaking a fixture slot.
Reproducible browsers
- Pin the browser -
motus installaccepts an exact Chromium revision, andlaunch.executablePathinmotus.config.jsonorMOTUS_EXECUTABLE_PATHin the environment points at a specific binary. A path passed in code still wins, so the precedence is explicit rather than surprising. Pinning is what makes a CI run reproducible when the stable channel moves underneath it. - Windows sandbox access - Chromium unzipped into a user directory is granted the ACLs its sandbox needs, during install and when repairing an existing install. A failure is reported without aborting the install.
Seeing what the automation did
- On-screen cursor and natural mouse motion -
ContextOptions.ShowCursordraws a pseudo-cursor and click effects into the page, so a screenshot or a recording shows where the pointer was and when it clicked, which is otherwise invisible.NaturalMouseMotionmoves in eased multi-step paths rather than teleporting, which both looks right in a recording and satisfies pages that require observed movement.--show-cursorand--natural-mouseexpose both to the MCP server, and--show-cursorturns on natural motion by default since a cursor that teleports is worse than none. - Recordings play back at the right speed - The recorder measures the rate it actually captured at and patches the AVI timing headers when finalizing, so playback matches real time instead of drifting from the nominal frame rate.
Documentation
- Packages ship IntelliSense - The assertion and reporter APIs (
Expect,LocatorAssertions,PageAssertions,ResponseAssertions,ReporterCollection) are documented, and the fourMotus.Testingpackages now generate XML documentation at all. Assertions are the most-used surface in the library and had none of this, so the entry point every test goes through was undocumented in the editor. - Four new guides - Attaching to a Running Browser covers debugging endpoints, ownership, CI and container patterns, signed-in profiles, desktop applications, and the security implications in full. Frames and iframes covers traversal, out-of-process frames, execution worlds, and two traps that cost real time to rediscover. Sharding covers partitioning, merging, and the missing-shard failure that looks like a passing run. Flaky Tests and Quarantine covers retry policies, what counts as flaky, quarantine, and flake history.
- A CLI reference on the site - Every command, argument, option, default and exit code now has a page of its own at CLI Reference. Twelve commands, including the three that were previously documented nowhere at all:
trx show,shard mergeandcheck-selectors. The package README, which had been the only listing and had drifted from the tool it described, now points at it rather than repeating it. - Existing guides caught up - The Playwright migration guide maps
connectOverCDPandframeLocatorby name. Configuration documents theflaky,shardandcoveragesections,launch.executablePath, and eleven environment variables that were previously undocumented. The coverage section covers where thresholds may be set and the two cases that silently yield no data. Test framework integration covers retrying a test that lost its browser, browser lifecycle covers pinning an exact browser revision, and the MCP guide covers the newevaluateresult shape along with the cursor, viewport and recovery options.
Behavior changes
CloseAsyncno longer ends a browser Motus did not start - This was a defect: closing an attached browser sentBrowser.closeand terminated a process belonging to somebody else. It now closes the contexts Motus created and disconnects. If you were relying onCloseAsyncto end a browser you connected to, end the process yourself;DisposeAsyncwill not do it either, and never did.- A locator from
IFramenow resolves inside that frame -frame.Locator(...)and theGetBy*factories beside it previously built a page-rooted locator and resolved against the main frame regardless of which frame was asked. Any test that leaned on that fall-through will start failing, and the failure will look like a regression when it is the fix. Usepage.Locator(...)where the main frame was what you actually wanted. ILocator.BoundingBoxAsyncanswers in page coordinates for a frame-rooted locator - It previously measured in the frame's own coordinate space, so a box handed topage.Mousemissed by the frame's offset. Code that was correcting for that offset by hand should stop.IPage.ScreenshotAsynchonorsScreenshotOptions.Clip- The clip was accepted and then dropped, so a caller asking for a region was handed the whole viewport and nothing said otherwise. It now captures the region asked for. Anyone who set a clip and relied on getting the full viewport back will see a different image, and anyone who set one and wondered why it did nothing will see it work.- An assertion that lost the browser now reports the loss rather than a failure - A retrying assertion treats the target going away as something to poll through, because during a navigation the old execution context dies and the next attempt succeeds against the new one. When the browser itself is gone no attempt ever succeeds, so the assertion ran out its timeout and reported
Received: <not evaluated>: a verdict about the page stated by a test that never reached one. Worse, it hid the loss fromBrowserFailure.IsBrowserLost, which is exactly what[MotusTestClass]and--retry-policy transientask before re-running, so the one failure worth retrying was the one they could not see. An assertion that never evaluated and ended with the target closed now propagates that instead. Assertions that fail on their merits, and elements that are simply absent, are unchanged. Code catchingMotusAssertionExceptionaround an assertion will seeMotusTargetClosedExceptionin this case. - MCP:
evaluatereturns its value under aresultkey - Structured content has to be a JSON object, so an expression returning a bare number, string, or array was rejected by the client before the model ever saw it, and the workaround was to wrap the expression by hand. Every value now comes back as{"result": ...}whatever its shape. Clients that were reading the value directly need to readresult; expressions that were wrapped by hand can stop. - MCP: a nullable tool parameter is no longer advertised as required - Twenty of the tools declared parameters that accept null and required them at the same time, so a client that sensibly omitted one got an argument error rather than the documented default. Those parameters are now optional and carry their default in the schema. Clients that were passing explicit nulls are unaffected.
Two of these were found by the exit criteria for the frame work rather than reported, and both predate it: the frame-rooted actionability checks and the bounding-box space were wrong for every frame locator, not only cross-origin ones.
Contracts
IFrame gains IsDetached, AccessibilitySnapshotAsync, LocatorByBackendNodeId, and an EvaluateAsync overload; IPage gains three frame events; IBrowser gains OwnsProcess and DisconnectAsync. TestResult and TestRunSummary gain Flaky, Quarantined and Attempts, and TestSuiteInfo gains ShardIndex and ShardTotal. These are additive for callers and breaking for anyone implementing the interfaces or constructing those records positionally, which in practice means test doubles and custom reporters.