feat: add getNodesByTitle and getNodeByTitleNth helpers to VueNodeHelpers

Add helpers for safely interacting with nodes that share the same title
(e.g. two "CLIP Text Encode" nodes) without hitting Playwright strict mode.

- getNodesByTitle(title): returns all matching nodes
- getNodeByTitleNth(title, index): convenience .nth() wrapper
- Updated docs/guidance/playwright.md with gotcha note
This commit is contained in:
bymyself
2026-03-28 00:55:34 -07:00
parent e34548724d
commit 74947b47a3
2 changed files with 19 additions and 1 deletions

View File

@@ -31,12 +31,29 @@ export class VueNodeHelpers {
}
/**
* Get locator for a Vue node by the node's title (displayed name in the header)
* Get locator for a Vue node by the node's title (displayed name in the header).
* Returns all matching nodes — use only when the title is unique.
* For non-unique titles, use {@link getNodesByTitle} with `.nth(n)`.
*/
getNodeByTitle(title: string): Locator {
return this.page.locator(`[data-node-id]`).filter({ hasText: title })
}
/**
* Get locator matching ALL Vue nodes with the given title.
* Callers should use `.nth(0)`, `.nth(1)`, etc. to pick a specific one.
*/
getNodesByTitle(title: string): Locator {
return this.page.locator(`[data-node-id]`).filter({ hasText: title })
}
/**
* Get locator for the nth Vue node matching the given title (0-indexed).
*/
getNodeByTitleNth(title: string, index: number): Locator {
return this.getNodesByTitle(title).nth(index)
}
/**
* Get total count of Vue nodes in the DOM
*/

View File

@@ -86,6 +86,7 @@ Tags are respected by config:
- Check `browser_tests/assets/` for test data and fixtures
- Use realistic ComfyUI workflows for E2E tests
- When multiple nodes can share the same name (e.g. two "CLIP Text Encode" nodes), use `vueNodes.getNodesByTitle(name).nth(n)` or `vueNodes.getNodeByTitleNth(name, n)`. Never use `getNodeByTitle` for non-unique names — Playwright strict mode will fail.
## Running Tests