diff --git a/skyvern/webeye/scraper/domUtils.js b/skyvern/webeye/scraper/domUtils.js index 2fdf7631..1dc227af 100644 --- a/skyvern/webeye/scraper/domUtils.js +++ b/skyvern/webeye/scraper/domUtils.js @@ -665,13 +665,7 @@ function buildTreeFromBody(frame = "main.frame") { var element_id = element.getAttribute("unique_id") ?? uniqueId(); var elementTagNameLower = element.tagName.toLowerCase(); element.setAttribute("unique_id", element_id); - // if element is an "a" tag and has a target="_blank" attribute, remove the target attribute - // We're doing this so that skyvern can do all the navigation in a single page/tab and not open new tab - if (element.tagName.toLowerCase() === "a") { - if (element.getAttribute("target") === "_blank") { - element.removeAttribute("target"); - } - } + const attrs = {}; for (const attr of element.attributes) { var attrValue = attr.value; @@ -762,6 +756,14 @@ function buildTreeFromBody(frame = "main.frame") { return; } + // if element is an "a" tag and has a target="_blank" attribute, remove the target attribute + // We're doing this so that skyvern can do all the navigation in a single page/tab and not open new tab + if (element.tagName.toLowerCase() === "a") { + if (element.getAttribute("target") === "_blank") { + element.removeAttribute("target"); + } + } + // Check if the element is interactable if (isInteractable(element)) { var elementObj = buildElementObject(element, true);