FIx corner cases (val connection in chrome when using playwright, and action parsing for agent, and accessibility tree xml handling)
This commit is contained in:
@@ -159,9 +159,19 @@ def get_open_tabs_info(env, config: Dict[str, str]):
|
||||
tabs_info = []
|
||||
for context in browser.contexts:
|
||||
for page in context.pages:
|
||||
title = page.title()
|
||||
url = page.url
|
||||
tabs_info.append({'title': title, 'url': url})
|
||||
try:
|
||||
# Wait for the page to finish loading, this prevents the "execution context was destroyed" issue
|
||||
page.wait_for_load_state('load') # Wait for the 'load' event to complete
|
||||
title = page.title()
|
||||
url = page.url
|
||||
tabs_info.append({'title': title, 'url': url})
|
||||
except TimeoutError:
|
||||
# If page loading times out, catch the exception and store the current information in the list
|
||||
tabs_info.append({'title': 'Load timeout', 'url': page.url})
|
||||
except Exception as e:
|
||||
# Catch other potential exceptions that might occur while reading the page title
|
||||
print(f'Error: {e}')
|
||||
tabs_info.append({'title': 'Error encountered', 'url': page.url})
|
||||
|
||||
browser.close()
|
||||
return tabs_info
|
||||
|
||||
Reference in New Issue
Block a user