Skip to content

Commit

Permalink
Added context to default finder .. work in progress ..
Browse files Browse the repository at this point in the history
  • Loading branch information
emanlove committed Jan 6, 2025
1 parent ac2f3c3 commit 48aecde
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/SeleniumLibrary/locators/elementfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ def __getitem__(self, item):
def __len__(self):
pass

class DefaultElementFinder:
class DefaultElementFinder(ContextAware):
def __init__(self):
self._s = Strategies(self)

def pre_find_action(self):
pass

Expand All @@ -65,7 +68,7 @@ def find(self, locator, tag=None, first_only=True, required=True, parent=None):
if is_webelement(locator):
return locator
prefix, criteria = self._parse_locator(locator)
strategy = self._strategies[prefix]
strategy = self._s._strategies[prefix]
tag, constraints = self._get_tag_and_constraints(tag)
elements = strategy(criteria, tag, constraints, parent=parent or self.driver)
if required and not elements:
Expand Down Expand Up @@ -126,7 +129,7 @@ def _parse_locator(self, locator):
index = self._get_locator_separator_index(locator)
if index != -1:
prefix = locator[:index].strip()
if prefix in self._strategies:
if prefix in self._s._strategies:
return prefix, locator[index + 1 :].lstrip()
return "default", locator

Expand All @@ -150,6 +153,7 @@ def __init__(self, ctx):
# and register the default element finder (and others?) ...
# .. but for now hard code an instance of the defaultelementfinder
self._element_finder = DefaultElementFinder()
self._strategies = Strategies(ctx)


# I am wanting to rename what was called the find method
Expand Down

0 comments on commit 48aecde

Please sign in to comment.