Skip to content

Commit fa166da

Browse files
author
David Haeffner
committed
Fix for performance issue with the xpath:innerText locator builder strategy
1 parent d29392d commit fa166da

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

packages/selenium-ide/src/content/locatorBuilders.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -491,18 +491,12 @@ LocatorBuilders.add('xpath:position', function(e, opt_contextNode) {
491491
})
492492

493493
LocatorBuilders.add('xpath:innerText', function(el) {
494-
const initialXpath = `//*[contains(.,'${el.innerText}')]`
495-
const xpathResults = document.evaluate(
496-
initialXpath,
497-
document,
498-
null,
499-
XPathResult.ORDERED_NODE_ITERATOR_TYPE,
500-
null
501-
)
502-
let result = xpathResults.iterateNext()
503-
while (result) {
504-
if (result === el) break
505-
result = xpathResults.iterateNext()
494+
if (el.innerText) {
495+
const initialXpath = `//${el.nodeName.toLowerCase()}[contains(.,'${
496+
el.innerText
497+
}')]`
498+
return this.preciseXPath(initialXpath, el)
499+
} else {
500+
return null
506501
}
507-
return result ? this.preciseXPath(initialXpath, el) : null
508502
})

0 commit comments

Comments
 (0)