Skip to content

Commit

Permalink
seleneium: disable caching. fix bugs. move find_anything into try-exc…
Browse files Browse the repository at this point in the history
…ept.
  • Loading branch information
naisanzaa committed Nov 10, 2024
1 parent 61c1351 commit 9ade4c4
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions automon/integrations/seleniumWrapper/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ def find_anything(
case_sensitive: bool = False,
exact_match: bool = False,
return_first: bool = False,
caching: bool = True,
caching: bool = False,
**kwargs) -> list:
"""fuzzy search through everything
Expand Down Expand Up @@ -601,32 +601,32 @@ def find_anything(
MATCH = f'{match}'.lower()
AGAINST = f'''{getattr(element, f'{dir_}')}'''.lower()

except:
pass
FOUND = None

FOUND = None
if MATCH == AGAINST and exact_match:
FOUND = element

if MATCH == AGAINST and exact_match:
FOUND = element
if MATCH in AGAINST and not exact_match:
FOUND = element

if MATCH in AGAINST and not exact_match:
FOUND = element
if FOUND and FOUND not in MATCHED:
logger.debug(
f'find_anything :: '
f'{self.current_url} :: '
f'{MATCH=} :: '
f'{AGAINST=} :: '
f'attribute={dir_} :: '
f'{element=} :: '
f'found'
)
MATCHED.append(FOUND)

if FOUND and FOUND not in MATCHED:
logger.debug(
f'find_anything :: '
f'{self.current_url} :: '
f'{MATCH=} :: '
f'{AGAINST=} :: '
f'attribute={dir_} :: '
f'{element=} :: '
f'found'
)
MATCHED.append(FOUND)
if return_first:
logger.info(f'find_anything :: done')
return MATCHED

if return_first:
logger.info(f'find_anything :: done')
return MATCHED
except Exception as error:
logger.error(f'find_anything :: error :: {error=} :: {error.msg=}')

logger.debug(f'find_anything :: {len(MATCHED)} results found')
logger.info(f'find_anything :: done')
Expand All @@ -650,7 +650,7 @@ def find_elements(
self,
value: str,
by: selenium.webdriver.common.by.By,
caching: bool = True,
caching: bool = False,
**kwargs) -> list:
"""find elements"""
logger.debug(f'find_elements :: {self.current_url} :: {value=} :: {by=} :: {kwargs=}')
Expand Down Expand Up @@ -998,6 +998,7 @@ def wait_for_anything(
find = self.find_anything(
match=match,
value=value,
value_attr=value_attr,
by=by,
case_sensitive=case_sensitive,
exact_match=exact_match,
Expand Down

0 comments on commit 9ade4c4

Please sign in to comment.