Skip to content

Commit 48aecde

Browse files
committed
Added context to default finder .. work in progress ..
1 parent ac2f3c3 commit 48aecde

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/SeleniumLibrary/locators/elementfinder.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ def __getitem__(self, item):
5252
def __len__(self):
5353
pass
5454

55-
class DefaultElementFinder:
55+
class DefaultElementFinder(ContextAware):
56+
def __init__(self):
57+
self._s = Strategies(self)
58+
5659
def pre_find_action(self):
5760
pass
5861

@@ -65,7 +68,7 @@ def find(self, locator, tag=None, first_only=True, required=True, parent=None):
6568
if is_webelement(locator):
6669
return locator
6770
prefix, criteria = self._parse_locator(locator)
68-
strategy = self._strategies[prefix]
71+
strategy = self._s._strategies[prefix]
6972
tag, constraints = self._get_tag_and_constraints(tag)
7073
elements = strategy(criteria, tag, constraints, parent=parent or self.driver)
7174
if required and not elements:
@@ -126,7 +129,7 @@ def _parse_locator(self, locator):
126129
index = self._get_locator_separator_index(locator)
127130
if index != -1:
128131
prefix = locator[:index].strip()
129-
if prefix in self._strategies:
132+
if prefix in self._s._strategies:
130133
return prefix, locator[index + 1 :].lstrip()
131134
return "default", locator
132135

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

154158

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

0 commit comments

Comments
 (0)