fix : exception in browser

This commit is contained in:
martin legrand 2025-04-04 14:15:29 +02:00
parent ac5118c4e3
commit 5321dcc3ba
2 changed files with 12 additions and 3 deletions

View File

@ -270,9 +270,13 @@ class Browser:
raise e
def find_all_inputs(self, timeout=3):
WebDriverWait(self.driver, timeout).until(
EC.presence_of_element_located((By.TAG_NAME, "body"))
)
try:
WebDriverWait(self.driver, timeout).until(
EC.presence_of_element_located((By.TAG_NAME, "body"))
)
except Exception as e:
self.logger.error(f"Error waiting for input element: {str(e)}")
return []
time.sleep(0.5)
script = self.load_js("find_inputs.js")
input_elements = self.driver.execute_script(script)
@ -359,6 +363,9 @@ class Browser:
except TimeoutException:
self.logger.warning(f"Timeout waiting for '{button_text}' button at XPath: {xpath}")
return False
except Exception as e:
self.logger.error(f"Error clicking button '{button_text}' at XPath: {xpath} - {str(e)}")
return False
self.logger.warning(f"No button matching '{btn_type}' found")
return False

View File

@ -93,6 +93,8 @@ class Interaction:
self.recorder.join()
self.transcriber.join()
query = self.transcriber.get_transcript()
if query == "exit" or query == "goodbye":
return None
return query
def get_user(self) -> str: