MCPcopy Create free account
hub / github.com/InverseUI/InverseUI-Recorder / validateXPath

Function validateXPath

util/xpath_utils.js:181–201  ·  view source on GitHub ↗
(xpath)

Source from the content-addressed store, hash-verified

179 * Validate XPath syntax and uniqueness
180 */
181export function validateXPath(xpath) {
182 try {
183 const result = document.evaluate(xpath, document, null, XPathResult.ANY_TYPE, null);
184 let count = 0;
185 let node = result.iterateNext();
186 while (node) {
187 count++;
188 node = result.iterateNext();
189 }
190 return {
191 valid: true,
192 count: count,
193 isUnique: count === 1
194 };
195 } catch (e) {
196 return {
197 valid: false,
198 error: e.message
199 };
200 }
201}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected