From da66d66132bf126155f9e8ab9053133b954de533 Mon Sep 17 00:00:00 2001 From: LawyZheng Date: Wed, 10 Jul 2024 14:55:59 +0800 Subject: [PATCH] fix id selector (#573) --- skyvern/webeye/scraper/domUtils.js | 4 ++-- skyvern/webeye/utils/dom.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/skyvern/webeye/scraper/domUtils.js b/skyvern/webeye/scraper/domUtils.js index ed302212..325b3509 100644 --- a/skyvern/webeye/scraper/domUtils.js +++ b/skyvern/webeye/scraper/domUtils.js @@ -630,14 +630,14 @@ async function getSelect2OptionElements(element) { while (true) { oldOptionCount = optionList.length; let newOptionList = document.querySelectorAll( - "#select2-drop li[role='option']", + "[id='select2-drop'] li[role='option']", ); if (newOptionList.length === oldOptionCount) { console.log("no more options loaded, wait 5s to query again"); // sometimes need more time to load the options, so sleep 10s and try again await sleep(5000); // wait 5s newOptionList = document.querySelectorAll( - "#select2-drop li[role='option']", + "[id='select2-drop'] li[role='option']", ); console.log(newOptionList.length, " options found, after 5s"); } diff --git a/skyvern/webeye/utils/dom.py b/skyvern/webeye/utils/dom.py index 3c916276..5ccaf239 100644 --- a/skyvern/webeye/utils/dom.py +++ b/skyvern/webeye/utils/dom.py @@ -197,7 +197,7 @@ class SkyvernElement: if for_id == "": return None - locator = self.get_frame().locator(f"#{for_id}") + locator = self.get_frame().locator(f"[id='{for_id}']") # supposed to be only one element, since id is unique in the whole DOM if await locator.count() != 1: return None @@ -349,7 +349,7 @@ class Select2Dropdown(AbstractSelectDropdown): self.frame = frame async def __find_anchor(self, timeout: float) -> Locator: - locator = self.frame.locator("#select2-drop") + locator = self.frame.locator("[id='select2-drop']") await locator.wait_for(state="visible", timeout=timeout) cnt = await locator.count() if cnt == 0: @@ -415,7 +415,7 @@ class ComboboxDropdown(AbstractSelectDropdown): async def __find_anchor(self, timeout: float) -> Locator: control_id = await self.skyvern_element.get_attr("aria-controls", timeout=timeout) - locator = self.frame.locator(f"#{control_id}") + locator = self.frame.locator(f"[id='{control_id}']") await locator.wait_for(state="visible", timeout=timeout) cnt = await locator.count() if cnt == 0: