From 2fb2a51c8212744b5a419d485803159652010e50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=B4=AA=E7=A3=8A?= <1017368065@qq.com> Date: Fri, 13 Mar 2026 02:59:09 +0800 Subject: [PATCH] fix: update handleGetText to use innerText for improved text retrieval (#729) The handleGetText function now retrieves text using innerText, falling back to textContent if innerText is not available. This change enhances the accuracy of text extraction from elements. Co-authored-by: Honglei Wu --- src/actions.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/actions.ts b/src/actions.ts index 0addd56..8b7661e 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -1671,7 +1671,8 @@ async function handleGetAttribute( async function handleGetText(command: GetTextCommand, browser: BrowserManager): Promise { const page = browser.getPage(); const locator = browser.getLocator(command.selector); - const text = await locator.textContent(); + const inner = await locator.innerText(); + const text = inner || (await locator.textContent()) || ''; return successResponse(command.id, { text, origin: page.url() }); }