Skip to content

Automate browser based workflows with AI

support table parse (#708)

LawyZheng4a8b1473ec20
diff --git a/skyvern/webeye/scraper/domUtils.js b/skyvern/webeye/scraper/domUtils.js
index 4961ecfd8..0c9146caa 100644
--- a/skyvern/webeye/scraper/domUtils.js
+++ b/skyvern/webeye/scraper/domUtils.js
@@ -303,6 +303,22 @@ function hasWidgetRole(element) {
return widgetRoles.includes(role.toLowerCase().trim());
}
+function isTableRelatedElement(element) {
+ const tagName = element.tagName.toLowerCase();
+ return [
+ "table",
+ "caption",
+ "thead",
+ "tbody",
+ "tfoot",
+ "tr",
+ "th",
+ "td",
+ "colgroup",
+ "col",
+ ].includes(tagName);
+}
+
function isInteractableInput(element) {
const tagName = element.tagName.toLowerCase();
const type = element.getAttribute("type") ?? "text"; // Default is text: https://www.w3schools.com/html/html_form_input_types.asp
@@ -1051,6 +1067,10 @@ async function buildElementTree(
} else if (isParentSVG && isParentSVG.getAttribute("unique_id")) {
// if elemnet is the children of the <svg> with an unique_id
elementObj = await buildElementObject(element, false);
+ } else if (isTableRelatedElement(element)) {
+ // build all table related elements into skyvern element
+ // we need these elements to preserve the DOM structure
+ elementObj = await buildElementObject(element, false);
} else {
// character length limit for non-interactable elements should be 5000
// we don't use element context in HTML format,