Skip to content

Automate browser based workflows with AI

fix yes/no radio input (#955)

LawyZheng3a935584d056
diff --git a/skyvern/webeye/scraper/domUtils.js b/skyvern/webeye/scraper/domUtils.js
index 0fe857e71..a82f13a40 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 96d3ec634..8dd67ed6b 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