[v4]: add index to selector schemas
Merged
SE
8mo ago+33+33+01234567890123456789-0-0-0123456789
why
- selectors can resolve to multiple nodes
- we need to give the user freedom to optionally provide an
index, indicating the desired element if multiple are found
what changed
- added an optional
indexfield toXPathSelectorSchema,CssSelectorSchema&TextSelectorSchema - note:
CoordinateSelectorSchemaremains unchanged, since coordinates are inherently specific
selector schema before:
selector schema after:
test plan
- added new test case in
packages/server-v4/src/schemas/v4/page.ts
Summary by cubic
Adds an optional non-negative idx to XPath, CSS, and text selectors so callers can target a specific element when a selector matches multiple nodes. Updates the v4 schema and OpenAPI spec without breaking existing clients.
- New Features
- Added optional non-negative
idxtoXPathSelectorSchema,CssSelectorSchema, andTextSelectorSchema. - Left
CoordinateSelectorSchemaunchanged. - Updated
openapi.v4.yamlwith the newidxfield and examples. - Expanded integration tests to cover
css,xpath, andtextselectors withidx.
- Added optional non-negative