From 112269ce1d0e4ff5829d81fa7a80706558b1559d Mon Sep 17 00:00:00 2001 From: LawyZheng Date: Mon, 29 Jul 2024 23:40:13 +0800 Subject: [PATCH] fix select2 multi-select (#656) --- skyvern/webeye/scraper/domUtils.js | 8 ++------ skyvern/webeye/utils/dom.py | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/skyvern/webeye/scraper/domUtils.js b/skyvern/webeye/scraper/domUtils.js index ec7d1f81..ffb6b170 100644 --- a/skyvern/webeye/scraper/domUtils.js +++ b/skyvern/webeye/scraper/domUtils.js @@ -648,16 +648,12 @@ async function getSelect2OptionElements(element) { while (true) { oldOptionCount = optionList.length; - let newOptionList = document.querySelectorAll( - "[id='select2-drop'] li[role='option']", - ); + let newOptionList = document.querySelectorAll("[id='select2-drop'] ul li"); 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( - "[id='select2-drop'] li[role='option']", - ); + newOptionList = document.querySelectorAll("[id='select2-drop'] ul li"); console.log(newOptionList.length, " options found, after 5s"); } diff --git a/skyvern/webeye/utils/dom.py b/skyvern/webeye/utils/dom.py index 06f0c515..5598aa8a 100644 --- a/skyvern/webeye/utils/dom.py +++ b/skyvern/webeye/utils/dom.py @@ -426,7 +426,7 @@ class Select2Dropdown(AbstractSelectDropdown): self, index: int, timeout: float = SettingsManager.get_settings().BROWSER_ACTION_TIMEOUT_MS ) -> None: anchor = await self.__find_anchor(timeout=timeout) - options = anchor.locator("li[role='option']") + options = anchor.locator("ul").locator("li") await options.nth(index).click(timeout=timeout)