MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / buildXPath

Function buildXPath

lib/command/query.js:100–117  ·  view source on GitHub ↗
(input, options)

Source from the content-addressed store, hash-verified

98}
99
100function buildXPath(input, options) {
101 const literal = xpathLocator.literal(input)
102 if (options.field) return Locator.field.byText(literal)
103 if (options.click || options.clickable) return Locator.clickable.wide(literal)
104 if (options.checkable) return Locator.checkable.byText(literal)
105 if (options.select) {
106 return Locator.select.byVisibleText(literal).replace(/\.\/(option|optgroup)/g, './/$1')
107 }
108
109 if (options.xpath) return new Locator({ xpath: input }).toXPath()
110 if (options.css) return new Locator({ css: input }).toXPath()
111
112 const loc = new Locator(input)
113 if (loc.type === 'fuzzy') {
114 return xpathLocator.combine([Locator.clickable.wide(literal), Locator.field.byText(literal)])
115 }
116 return loc.toXPath()
117}
118
119function htmlToDoc(html) {
120 const p5doc = parse5.parse(html, { sourceCodeLocationInfo: true })

Callers 1

queryFunction · 0.85

Calls 1

toXPathMethod · 0.95

Tested by

no test coverage detected