Skip to content

motus-v1.0.10

Choose a tag to compare

@github-actions github-actions released this 21 Apr 00:47
· 82 commits to main since this release

Selector repair and maintenance tooling lands as the headline feature, alongside DOM-scoped locator chains and parent-navigation selectors that bring resolution semantics in line with Playwright.

Improvements

  • motus check-selectors CLI command - New command that parses Locator, GetByRole, GetByText, GetByTestId, GetByLabel, GetByPlaceholder, GetByAltText, and GetByTitle calls out of C# sources via Roslyn, launches a browser, and reports each selector as HEALTHY, BROKEN, AMBIGUOUS, or SKIPPED against a live page. Supports --base-url for simple validation, --manifest for per-selector URL routing, --ci for non-zero exit on breakage, and --json for machine-readable output.
  • Selector manifests from record and codegen - Both commands now emit a <TestName>.selectors.json sidecar containing each locator's selector string, locator method, source file and line, captured page URL, and a DomFingerprint (tag name, key attributes, visible text, ancestor path, SHA-256 hash) built from DOM.describeNode and DOM.getOuterHTML. The manifest is the input that lets check-selectors navigate to the right page per selector and run fingerprint-based repair suggestions.
  • Repair suggestion pipeline and --fix - For every broken selector with a fingerprint match on the live page, the repair pipeline runs the DOM element through each registered ISelectorStrategy (testid → role → text → CSS by default) and grades candidates as High, Medium, or Low confidence. motus check-selectors --fix rewrites High-confidence replacements back into source via a Roslyn SyntaxRewriter that preserves trivia and formatting, writing .bak backups by default (suppressible with --no-backup).
  • Interactive repair in the visual runner - motus check-selectors --interactive opens the Blazor visual runner with a new SelectorRepairPanel. For each broken selector the panel shows the captured page with the candidate element highlighted via CDP DOM.highlightNode, the ranked repair suggestions, and accept/edit/skip controls. Accepted choices are written back to source through the same Roslyn rewriter used by --fix.
  • DOM-scoped child locators - page.Locator(parent).Locator(child) now resolves the parent handle first and then runs querySelectorAll for the child selector under each parent via Runtime.callFunctionOn, flattening and deduplicating results in parent-list order. Parents found via non-CSS strategies (xpath=, role=, text=, data-testid=) chain correctly because the parent handle is already materialized before the descendant query runs. Replaces the prior CSS-concatenation model, which silently produced wrong results when a non-CSS parent was chained with a CSS child.
  • Parent-navigation chains - Locator(parent).Locator("..").Locator(grandchild) walks from each parent match up one parentElement hop (or "../.." for two, etc.) before the next descendant query. ElementNotFoundException diagnostics distinguish "no parent match" from "parent matched but descendant didn't" and hint at portal-rendered DOM when the parent matched.
  • ILocator.EvaluateWithElementAsync - New method matching Playwright's convention where el => el.foo receives the element as the first argument, distinct from the existing EvaluateAsync which binds the element as this for function() { ... } literals. Doc comments on both methods now spell out which idiom to use when.
  • Smarter Evaluate/WaitForFunction argument handling - Page.EvaluateAsync and Locator.EvaluateAsync now detect whether the supplied expression is a function literal, identifier arrow, or parenthesized arrow, and only wrap/invoke it when an argument is supplied. Non-function expressions with an argument now throw a clear error instead of producing a confusing CDP failure.

Bug Fixes

  • WaitForFunction cancellation handling - The polling loop inside WaitForFunction no longer leaks OperationCanceledException from Task.Delay. Cancellation now routes through the page's cancellation token so callers see the same exception type on timeout and on explicit cancel.
  • Selector manifest tests on Windows - Tests that hardcoded /tmp paths and bare directory separators now use Path.GetTempPath() and Path.GetFullPath so the assertions pass on both Windows and Unix test runners, including for .g.cs generated filenames.
  • Locator scoping tests no longer race under parallel sends - LocatorDomScopingTests previously used a FIFO fake WebSocket, which occasionally paired responses with the wrong in-flight request when the threadpool interleaved callFunctionOn sends with getProperties continuations. The tests now use a method-aware fake socket that synthesizes responses from the outbound envelope's method and objectId, making the suite reliable regardless of send ordering.