Skip to content

Commit

Permalink
Added unit tests for #1924
Browse files Browse the repository at this point in the history
Added a couple unit tests to verify markus-leben's fix (#1924) for
allowing colons within the value of the data locator.
  • Loading branch information
emanlove committed Nov 2, 2024
1 parent f21bc11 commit 09bbd7f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions utest/test/locators/test_elementfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,13 @@ def test_find_with_data(finder):
finder.find("data:id:my_id", tag="div", required=False)
verify(driver).find_elements(By.XPATH, '//*[@data-id="my_id"]')

def test_find_with_data_multiple_colons(finder):
driver = _get_driver(finder)
elements = _make_mock_elements("div", "a", "span", "a")
when(driver).find_elements(By.XPATH, '//*[@data-automation-id="foo:bar"]').thenReturn(elements)
result = finder.find("data:automation-id:foo:bar", first_only=False)
assert result == elements


def test_find_with_invalid_data(finder):
with pytest.raises(
Expand All @@ -297,6 +304,12 @@ def test_find_with_invalid_data(finder):
):
finder.find("data:", tag="div", required=False)

with pytest.raises(
ValueError,
match=r"^Provided selector \(:value\) is malformed\. Correct format: name:value\.",
):
finder.find("data::value", tag="div", required=False)


def test_find_with_locator_with_apos(finder):
driver = _get_driver(finder)
Expand Down

0 comments on commit 09bbd7f

Please sign in to comment.