Fix StaleElementReferenceException, add Ollama offline fallback, and PIL visual search generator

This commit is contained in:
abhijitgorde5-crypto
2026-08-29 23:41:57 +05:30
parent 9e919e4ae2
commit 27a98d9b93
6 changed files with 196 additions and 105 deletions
+19 -4
View File
@@ -122,11 +122,20 @@ class ElementSelectionUtils:
return self.driver.find_element(By.CSS_SELECTOR, '[id$="-tab-/dashboard"]')
def get_sidebar_section(self):
for section in self.driver.find_elements(By.TAG_NAME, "section"):
sections = self.driver.find_elements(By.TAG_NAME, "section")
for section in sections:
try:
# get_dom_attribute returns None for sections without an id,
# so normalise before comparing.
if (section.get_dom_attribute("id") or "").startswith("react-aria"):
sec_id = section.get_dom_attribute("id") or ""
if sec_id.startswith("react-aria") and section.is_displayed():
if section.find_elements(By.TAG_NAME, "a") or section.find_elements(By.TAG_NAME, "button"):
return section
except StaleElementReferenceException:
continue
for section in sections:
try:
sec_id = section.get_dom_attribute("id") or ""
if sec_id.startswith("react-aria"):
return section
except StaleElementReferenceException:
continue
@@ -160,6 +169,12 @@ class ElementSelectionUtils:
# The first link in the opened panel is the progress row, not an activity.
return self.get_sidebar_section().find_elements(By.TAG_NAME, "a")[1:]
def get_daily_set_element_by_index(self, index: int):
elements = self.get_daily_set_elements()
if index < len(elements):
return elements[index]
raise NoSuchElementException(f"daily set element at index {index} not found")
# ------------------------------------------------------------------
# explore on bing (absent in en-US, present in some other markets)
# ------------------------------------------------------------------