strymsg commited on
Commit
48a78fd
·
1 Parent(s): 427319e

Actualización 30 de Julio de 2025

Browse files
data/gobbo_tramites_pre.csv CHANGED
The diff for this file is too large to render. See raw diff
 
notebooks/análisis1.ipynb CHANGED
The diff for this file is too large to render. See raw diff
 
notebooks/gobbo-pre.ipynb CHANGED
The diff for this file is too large to render. See raw diff
 
src/common/selectors.py CHANGED
@@ -45,3 +45,39 @@ async def is_element_located(page, selector, *args):
45
  return True
46
  return False
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  return True
46
  return False
47
 
48
+
49
+ async def get_text_from_all_elements(self, locator):
50
+ """Gets the text from all elements that matches the locator.
51
+ When there are multiple elements the text is concat with ,
52
+ If no element is found returns an empty string
53
+ """
54
+ text = ''
55
+ if await is_element_located(self.page, locator):
56
+ web_elements = await self.page.locator(get_locator(locator)).all()
57
+ if len(web_elements) == 1:
58
+ return await web_elements[0].inner_text()
59
+
60
+ for web_element in web_elements:
61
+ text += await web_element.inner_text() + ','
62
+ return text
63
+
64
+
65
+ async def get_text_from_page_and_locator(p, locator: str, throw_exception=True):
66
+ """Returns the `inner_text' from the element find with the given locator
67
+
68
+ Parameters:
69
+ p (Page Object playwrigth): Page object from browser context to search in
70
+ locator: locator string
71
+ throw_exception (bool): If true, raises an exception when no element for the given
72
+ locator is found, otherwise will return an empty string
73
+ """
74
+ if not throw_exception:
75
+ txt = await p.locator(get_locator(locator)).inner_text()
76
+ return txt if txt is not None else ''
77
+
78
+ try:
79
+ return await p.locator(get_locator(locator)).inner_text()
80
+ except Exception as e:
81
+ LOGGER.error(f'Error getting element with locator {locator}')
82
+ LOGGER.error(LOGGER.format_exception(e))
83
+ raise e