* Get elements by different locator types, including strict locator * Should be used in custom helpers: * * ```js * const elements = await this.helpers['Playwright']._locate({name: 'password'}); * ```
(locator)
| 1747 | * ``` |
| 1748 | */ |
| 1749 | async _locate(locator) { |
| 1750 | const context = await this._getContext() |
| 1751 | |
| 1752 | if (this.frame) return findElements.call(this, this.frame, locator) |
| 1753 | |
| 1754 | const els = await findElements.call(this, context, locator) |
| 1755 | |
| 1756 | if (store.debugMode) { |
| 1757 | const previewElements = els.slice(0, 3) |
| 1758 | let htmls = await Promise.all(previewElements.map(el => elToString(el, previewElements.length))) |
| 1759 | if (els.length > 3) htmls.push('...') |
| 1760 | if (els.length > 1) { |
| 1761 | this.debugSection(`Elements (${els.length})`, htmls.join('|').trim()) |
| 1762 | } else if (els.length === 1) { |
| 1763 | this.debugSection('Element', htmls.join('|').trim()) |
| 1764 | } else { |
| 1765 | this.debug(`No elements found by ${JSON.stringify(locator).slice(0, 50)}....`) |
| 1766 | } |
| 1767 | } |
| 1768 | |
| 1769 | return els |
| 1770 | } |
| 1771 | |
| 1772 | /** |
| 1773 | * Get the first element by different locator types, including strict locator |
no test coverage detected