From 3a935584d0567d74a2584d8e31ca1765af5234b7 Mon Sep 17 00:00:00 2001 From: LawyZheng Date: Fri, 11 Oct 2024 10:48:41 +0800 Subject: [PATCH] fix yes/no radio input (#955) --- skyvern/webeye/scraper/domUtils.js | 10 ++++++++++ skyvern/webeye/scraper/scraper.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/skyvern/webeye/scraper/domUtils.js b/skyvern/webeye/scraper/domUtils.js index 0fe857e7..a82f13a4 100644 --- a/skyvern/webeye/scraper/domUtils.js +++ b/skyvern/webeye/scraper/domUtils.js @@ -850,6 +850,16 @@ function buildElementObject(frame, element, interactable, purgeable = false) { attrs["required"] = true; } + if ( + elementTagNameLower === "input" && + (element.type === "radio" || element.type === "checkbox") + ) { + // if checkbox and radio don't have "checked" and "aria-checked", add a checked="false" to help LLM understand + if (!("checked" in attrs) && !("aria-checked" in attrs)) { + attrs["checked"] = false; + } + } + if (elementTagNameLower === "input" || elementTagNameLower === "textarea") { attrs["value"] = element.value; } diff --git a/skyvern/webeye/scraper/scraper.py b/skyvern/webeye/scraper/scraper.py index 96d3ec63..8dd67ed6 100644 --- a/skyvern/webeye/scraper/scraper.py +++ b/skyvern/webeye/scraper/scraper.py @@ -573,7 +573,7 @@ def _trimmed_attributes(attributes: dict) -> dict: for key in attributes: if key == "role" and attributes[key] in ["listbox", "option"]: new_attributes[key] = attributes[key] - if key in RESERVED_ATTRIBUTES and attributes[key]: + if key in RESERVED_ATTRIBUTES: new_attributes[key] = attributes[key] return new_attributes