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 <honglei.wu@shopee.com>
This commit is contained in:
吴洪磊
2026-03-12 13:59:09 -05:00
committed by GitHub
co-authored by Honglei Wu
parent c562ef5bb7
commit 2fb2a51c82
+2 -1
View File
@@ -1671,7 +1671,8 @@ async function handleGetAttribute(
async function handleGetText(command: GetTextCommand, browser: BrowserManager): Promise<Response> {
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() });
}