Skip to content

Commit

Permalink
Split InputByLabelLocator for two cases
Browse files Browse the repository at this point in the history
  • Loading branch information
M1troll committed Apr 17, 2024
1 parent 7b0dd06 commit 5007ffb
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion pomcorn/locators/xpath_locators.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,18 @@ def __init__(self, text: str, exact: bool = False):
super().__init__(text=text, element="button", exact=exact)


class InputByLabelLocator(XPathLocator):
class InputInLabelLocator(XPathLocator):
"""Locator to looking for input with label by XPath.
Specify the query as the string
``//label[contains(., "label")]//input``, where ``label`` is the text of
the input label.
Example:
<label>Title</label>
<input value="Value">
</label>
"""

def __init__(self, label: str):
Expand All @@ -216,6 +221,28 @@ def __init__(self, label: str):
)


class InputByLabelLocator(XPathLocator):
"""Locator to looking for input next to label by XPath.
Specify the query as the string
``//label[contains(., "label")]/following-sibling::input``, where ``label``
is the text of the input label.
Example:
<div>
<label for="InputWithLabel">Title</label>
<input id="InputWithLabel" value="Value">
</div>
"""

def __init__(self, label: str):
"""Init XPathLocator."""
super().__init__(
query=f'//label[contains(., "{label}")]/following-sibling::input',
)


class TextAreaByLabelLocator(XPathLocator):
"""Locator to looking for textarea with label by XPath.
Expand Down

0 comments on commit 5007ffb

Please sign in to comment.