@@ -68,6 +68,13 @@ def test_strategy_case_is_not_changed():
68
68
_verify_parse_locator ("XPATH=//foo/bar " , "XPATH" , "//foo/bar " )
69
69
70
70
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
+
71
78
def test_remove_whitespace_around_prefix_and_separator ():
72
79
_verify_parse_locator ("class = foo" , "class" , "foo" )
73
80
_verify_parse_locator ("class : foo" , "class" , "foo" )
@@ -271,6 +278,26 @@ def test_find_with_tag(finder):
271
278
verify (driver ).find_elements (By .XPATH , "//div[(@id='test1' or @name='test1')]" )
272
279
273
280
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
+
274
301
def test_find_with_locator_with_apos (finder ):
275
302
driver = _get_driver (finder )
276
303
finder .find ("test '1'" , required = False )
0 commit comments