Skip to content

Commit ac2f3c3

Browse files
committed
.. getting there
Moving in the right direction. Now just need to figure out where Strategies belongs ..
1 parent 63b35dc commit ac2f3c3

File tree

1 file changed

+17
-59
lines changed

1 file changed

+17
-59
lines changed

src/SeleniumLibrary/locators/elementfinder.py

Lines changed: 17 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,23 @@ def _get_tag_and_constraints(self, tag):
120120
tag = "textarea"
121121
return tag, constraints
122122

123+
def _parse_locator(self, locator):
124+
if re.match(r"\(*//", locator):
125+
return "xpath", locator
126+
index = self._get_locator_separator_index(locator)
127+
if index != -1:
128+
prefix = locator[:index].strip()
129+
if prefix in self._strategies:
130+
return prefix, locator[index + 1 :].lstrip()
131+
return "default", locator
132+
133+
def _get_locator_separator_index(self, locator):
134+
if "=" not in locator:
135+
return locator.find(":")
136+
if ":" not in locator:
137+
return locator.find("=")
138+
return min(locator.find("="), locator.find(":"))
139+
123140

124141
class LocatorElementEngine(ContextAware):
125142
def __init__(self, ctx):
@@ -206,65 +223,6 @@ def _split_locator(self, locator: Union[str, list]) -> list:
206223
# return elements[0]
207224
# return elements
208225

209-
def _get_tag_and_constraints(self, tag):
210-
if tag is None:
211-
return None, {}
212-
tag = tag.lower()
213-
constraints = {}
214-
if tag == "link":
215-
tag = "a"
216-
if tag == "partial link":
217-
tag = "a"
218-
elif tag == "image":
219-
tag = "img"
220-
elif tag == "list":
221-
tag = "select"
222-
elif tag == "radio button":
223-
tag = "input"
224-
constraints["type"] = "radio"
225-
elif tag == "checkbox":
226-
tag = "input"
227-
constraints["type"] = "checkbox"
228-
elif tag == "text field":
229-
tag = "input"
230-
constraints["type"] = [
231-
"date",
232-
"datetime-local",
233-
"email",
234-
"month",
235-
"number",
236-
"password",
237-
"search",
238-
"tel",
239-
"text",
240-
"time",
241-
"url",
242-
"week",
243-
"file",
244-
]
245-
elif tag == "file upload":
246-
tag = "input"
247-
constraints["type"] = "file"
248-
elif tag == "text area":
249-
tag = "textarea"
250-
return tag, constraints
251-
252-
def _parse_locator(self, locator):
253-
if re.match(r"\(*//", locator):
254-
return "xpath", locator
255-
index = self._get_locator_separator_index(locator)
256-
if index != -1:
257-
prefix = locator[:index].strip()
258-
if prefix in self._strategies:
259-
return prefix, locator[index + 1 :].lstrip()
260-
return "default", locator
261-
262-
def _get_locator_separator_index(self, locator):
263-
if "=" not in locator:
264-
return locator.find(":")
265-
if ":" not in locator:
266-
return locator.find("=")
267-
return min(locator.find("="), locator.find(":"))
268226

269227
class Strategies(ContextAware):
270228
def __init__(self, ctx):

0 commit comments

Comments
 (0)