Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
add remove all unique ids (#3964)
LawyZheng4cf6757d0512
diff --git a/skyvern/webeye/scraper/domUtils.js b/skyvern/webeye/scraper/domUtils.jsindex 030589d91..5f5588d8c 100644--- a/skyvern/webeye/scraper/domUtils.js+++ b/skyvern/webeye/scraper/domUtils.js@@ -2725,6 +2725,34 @@ function isAnimationFinished() {return false;}+/**+ * Remove unique_id attribute from all elements on the page.+ * This includes elements in the main document and shadow DOM.+ */+function removeAllUniqueIds() {+ // Function to recursively remove unique_id from an element and its children+ const removeUniqueIdFromElement = (element) => {+ if (element.hasAttribute("unique_id")) {+ element.removeAttribute("unique_id");+ }++ // Process children in the main DOM+ for (const child of Array.from(element.children)) {+ removeUniqueIdFromElement(child);+ }++ // Process elements in shadow DOM if present+ if (element.shadowRoot) {+ for (const shadowChild of Array.from(element.shadowRoot.children)) {+ removeUniqueIdFromElement(shadowChild);+ }+ }+ };++ // Start from document.documentElement to process the entire page+ removeUniqueIdFromElement(document.documentElement);+}+/**// How to run the code:diff --git a/skyvern/webeye/utils/page.py b/skyvern/webeye/utils/page.pyindex a50cd2f06..f14361e8d 100644--- a/skyvern/webeye/utils/page.py+++ b/skyvern/webeye/utils/page.py@@ -486,6 +486,10 @@ class SkyvernFrame:js_script = "([element]) => getElementDomDepth(element)"return await self.evaluate(frame=self.frame, expression=js_script, arg=[element])+ async def remove_all_unique_ids(self) -> None:+ js_script = "() => removeAllUniqueIds()"+ await self.evaluate(frame=self.frame, expression=js_script)+@TraceManager.traced_async()async def build_tree_from_body(self,