@@ -68,6 +68,13 @@ def test_strategy_case_is_not_changed():
6868 _verify_parse_locator ("XPATH=//foo/bar " , "XPATH" , "//foo/bar " )
6969
7070
71+ def test_data_locator_parsing ():
72+ _verify_parse_locator ("data:id:my_id" , "data" , "id:my_id" )
73+ _verify_parse_locator (
74+ "data:automation:my_automation_id" , "data" , "automation:my_automation_id"
75+ )
76+
77+
7178def test_remove_whitespace_around_prefix_and_separator ():
7279 _verify_parse_locator ("class = foo" , "class" , "foo" )
7380 _verify_parse_locator ("class : foo" , "class" , "foo" )
@@ -271,6 +278,26 @@ def test_find_with_tag(finder):
271278 verify (driver ).find_elements (By .XPATH , "//div[(@id='test1' or @name='test1')]" )
272279
273280
281+ def test_find_with_data (finder ):
282+ driver = _get_driver (finder )
283+ finder .find ("data:id:my_id" , tag = "div" , required = False )
284+ verify (driver ).find_elements (By .XPATH , '//*[@data-id="my_id"]' )
285+
286+
287+ def test_find_with_invalid_data (finder ):
288+ with pytest .raises (
289+ ValueError ,
290+ match = r"^Provided selector \(id:\) is malformed\. Correct format: name:value\." ,
291+ ):
292+ finder .find ("data:id:" , tag = "div" , required = False )
293+
294+ with pytest .raises (
295+ ValueError ,
296+ match = r"^Provided selector \(\) is malformed\. Correct format: name:value\." ,
297+ ):
298+ finder .find ("data:" , tag = "div" , required = False )
299+
300+
274301def test_find_with_locator_with_apos (finder ):
275302 driver = _get_driver (finder )
276303 finder .find ("test '1'" , required = False )
0 commit comments