Skip to content

Commit

Permalink
Merge pull request #1926 from emanlove/fix-find-by-data-locator-#1924
Browse files Browse the repository at this point in the history
Fix find by data locator #1924
  • Loading branch information
emanlove authored Nov 2, 2024
2 parents 96fa446 + 09bbd7f commit 1d6aa86
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 1d6aa86

Please sign in to comment.