From 36e0353dce189c10438924439d09a4d6407ab8bd Mon Sep 17 00:00:00 2001 From: Shelton Xia <79330016+chengxuan-xia@users.noreply.github.com> Date: Wed, 2 Aug 2023 18:49:38 -0700 Subject: [PATCH] Update selenium.py debug when button_text is empty --- chromegpt/tools/selenium.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/chromegpt/tools/selenium.py b/chromegpt/tools/selenium.py index 50b83cc..0210bc1 100644 --- a/chromegpt/tools/selenium.py +++ b/chromegpt/tools/selenium.py @@ -349,15 +349,27 @@ def _get_interactable_elements(self, soup: BeautifulSoup) -> str: interactable_texts = [] for element in interactable_elements: - button_text = find_parent_element_text(element) - button_text = prettify_text(button_text, 50) + # Detect if size is visible + if element.get("style") and "display: none" in element.get("style"): + continue if ( - button_text - and button_text not in interactable_texts - and element.is_displayed() - and element.is_enabled() + "style" in element.attrs + and "display: none" in element["style"] ): - interactable_texts.append(button_text) + continue + + button_text = ( + element.get("name") + or element.get("aria-label") + or element.get("value") + or element.get("id") + or find_parent_element_text(element) + ) + + if button_text: + button_text = prettify_text(button_text, limit=50, remove_special_char=True) + if button_text not in interactable_texts: + interactable_texts.append(button_text) # Split up the links and the buttons buttons_text = []