Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/SeleniumLibrary/locators/elementfinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def _find_by_tag_name(self, criteria, tag, constraints, parent):

def _find_by_data_locator(self, criteria, tag, constraints, parent):
try:
name, value = criteria.split(":", 2)
name, value = criteria.split(":", 1)
if "" in [name, value]:
raise ValueError
except ValueError:
Expand Down
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