mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +00:00
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:
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user