* {{> grabTextFrom }} *
(locator)
| 2704 | * |
| 2705 | */ |
| 2706 | async grabTextFrom(locator) { |
| 2707 | const roleElements = await handleRoleLocator(this.page, locator) |
| 2708 | if (roleElements && roleElements.length > 0) { |
| 2709 | const text = await roleElements[0].textContent() |
| 2710 | assertElementExists(text, JSON.stringify(locator)) |
| 2711 | this.debugSection('Text', text) |
| 2712 | return text |
| 2713 | } |
| 2714 | |
| 2715 | const locatorObj = new Locator(locator, 'css') |
| 2716 | |
| 2717 | locator = this._contextLocator(locator) |
| 2718 | try { |
| 2719 | const text = await this.page.textContent(locator) |
| 2720 | assertElementExists(text, locator) |
| 2721 | this.debugSection('Text', text) |
| 2722 | return text |
| 2723 | } catch (error) { |
| 2724 | // Convert Playwright timeout errors to ElementNotFound for consistency |
| 2725 | if (error.message && error.message.includes('Timeout')) { |
| 2726 | throw new ElementNotFound(locator, 'text') |
| 2727 | } |
| 2728 | throw error |
| 2729 | } |
| 2730 | } |
| 2731 | |
| 2732 | /** |
| 2733 | * {{> grabTextFromAll }} |
nothing calls this directly
no test coverage detected