diff --git a/lib/locator.js b/lib/locator.js index 5fa6ad5e7..9c427f20a 100644 --- a/lib/locator.js +++ b/lib/locator.js @@ -133,7 +133,7 @@ class Locator { if (position === 0) { throw new Error('0 is not valid element position. XPath expects first element to have index 1'); } - const xpath = sprintf('%s[position()=%s]', this.toXPath(), position); + const xpath = sprintf('(%s)[position()=%s]', this.toXPath(), position); return new Locator({ xpath }); }