From 09bbd7f7a056039e144b7e985a2b0b0d1f48a341 Mon Sep 17 00:00:00 2001 From: Ed Manlove Date: Sat, 2 Nov 2024 16:07:08 -0400 Subject: [PATCH] Added unit tests for #1924 Added a couple unit tests to verify markus-leben's fix (#1924) for allowing colons within the value of the data locator. --- utest/test/locators/test_elementfinder.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/utest/test/locators/test_elementfinder.py b/utest/test/locators/test_elementfinder.py index ed7b801bd..50472be20 100644 --- a/utest/test/locators/test_elementfinder.py +++ b/utest/test/locators/test_elementfinder.py @@ -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( @@ -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)