@@ -51,6 +51,7 @@ async def _expect_impl(
51
51
expect_options : FrameExpectOptions ,
52
52
expected : Any ,
53
53
message : str ,
54
+ title : str = None ,
54
55
) -> None :
55
56
__tracebackhide__ = True
56
57
expect_options ["isNot" ] = self ._is_not
@@ -60,7 +61,7 @@ async def _expect_impl(
60
61
message = message .replace ("expected to" , "expected not to" )
61
62
if "useInnerText" in expect_options and expect_options ["useInnerText" ] is None :
62
63
del expect_options ["useInnerText" ]
63
- result = await self ._actual_locator ._expect (expression , expect_options )
64
+ result = await self ._actual_locator ._expect (expression , expect_options , title )
64
65
if result ["matches" ] == self ._is_not :
65
66
actual = result .get ("received" )
66
67
if self ._custom_message :
@@ -105,6 +106,7 @@ async def to_have_title(
105
106
FrameExpectOptions (expectedText = expected_values , timeout = timeout ),
106
107
titleOrRegExp ,
107
108
"Page title expected to be" ,
109
+ 'Expect "to_have_title"' ,
108
110
)
109
111
110
112
async def not_to_have_title (
@@ -129,6 +131,7 @@ async def to_have_url(
129
131
FrameExpectOptions (expectedText = expected_text , timeout = timeout ),
130
132
urlOrRegExp ,
131
133
"Page URL expected to be" ,
134
+ 'Expect "to_have_url"' ,
132
135
)
133
136
134
137
async def not_to_have_url (
@@ -190,6 +193,7 @@ async def to_contain_text(
190
193
),
191
194
expected ,
192
195
"Locator expected to contain text" ,
196
+ 'Expect "to_contain_text"' ,
193
197
)
194
198
else :
195
199
expected_text = to_expected_text_values (
@@ -207,6 +211,7 @@ async def to_contain_text(
207
211
),
208
212
expected ,
209
213
"Locator expected to contain text" ,
214
+ 'Expect "to_contain_text"' ,
210
215
)
211
216
212
217
async def not_to_contain_text (
@@ -241,6 +246,7 @@ async def to_have_attribute(
241
246
),
242
247
value ,
243
248
"Locator expected to have attribute" ,
249
+ 'Expect "to_have_attribute"' ,
244
250
)
245
251
246
252
async def not_to_have_attribute (
@@ -276,6 +282,7 @@ async def to_have_class(
276
282
FrameExpectOptions (expectedText = expected_text , timeout = timeout ),
277
283
expected ,
278
284
"Locator expected to have class" ,
285
+ 'Expect "to_have_class"' ,
279
286
)
280
287
else :
281
288
expected_text = to_expected_text_values ([expected ])
@@ -284,6 +291,7 @@ async def to_have_class(
284
291
FrameExpectOptions (expectedText = expected_text , timeout = timeout ),
285
292
expected ,
286
293
"Locator expected to have class" ,
294
+ 'Expect "to_have_class"' ,
287
295
)
288
296
289
297
async def not_to_have_class (
@@ -318,6 +326,7 @@ async def to_contain_class(
318
326
FrameExpectOptions (expectedText = expected_text , timeout = timeout ),
319
327
expected ,
320
328
"Locator expected to contain class names" ,
329
+ 'Expect "to_contain_class"' ,
321
330
)
322
331
else :
323
332
expected_text = to_expected_text_values ([expected ])
@@ -326,6 +335,7 @@ async def to_contain_class(
326
335
FrameExpectOptions (expectedText = expected_text , timeout = timeout ),
327
336
expected ,
328
337
"Locator expected to contain class" ,
338
+ 'Expect "to_contain_class"' ,
329
339
)
330
340
331
341
async def not_to_contain_class (
@@ -350,6 +360,7 @@ async def to_have_count(
350
360
FrameExpectOptions (expectedNumber = count , timeout = timeout ),
351
361
count ,
352
362
"Locator expected to have count" ,
363
+ 'Expect "to_have_count"' ,
353
364
)
354
365
355
366
async def not_to_have_count (
@@ -375,6 +386,7 @@ async def to_have_css(
375
386
),
376
387
value ,
377
388
"Locator expected to have CSS" ,
389
+ 'Expect "to_have_css"' ,
378
390
)
379
391
380
392
async def not_to_have_css (
@@ -398,6 +410,7 @@ async def to_have_id(
398
410
FrameExpectOptions (expectedText = expected_text , timeout = timeout ),
399
411
id ,
400
412
"Locator expected to have ID" ,
413
+ 'Expect "to_have_id"' ,
401
414
)
402
415
403
416
async def not_to_have_id (
@@ -422,6 +435,7 @@ async def to_have_js_property(
422
435
),
423
436
value ,
424
437
"Locator expected to have JS Property" ,
438
+ 'Expect "to_have_property"' ,
425
439
)
426
440
427
441
async def not_to_have_js_property (
@@ -445,6 +459,7 @@ async def to_have_value(
445
459
FrameExpectOptions (expectedText = expected_text , timeout = timeout ),
446
460
value ,
447
461
"Locator expected to have Value" ,
462
+ 'Expect "to_have_value"' ,
448
463
)
449
464
450
465
async def not_to_have_value (
@@ -469,6 +484,7 @@ async def to_have_values(
469
484
FrameExpectOptions (expectedText = expected_text , timeout = timeout ),
470
485
values ,
471
486
"Locator expected to have Values" ,
487
+ 'Expect "to_have_values"' ,
472
488
)
473
489
474
490
async def not_to_have_values (
@@ -512,6 +528,7 @@ async def to_have_text(
512
528
),
513
529
expected ,
514
530
"Locator expected to have text" ,
531
+ 'Expect "to_have_text"' ,
515
532
)
516
533
else :
517
534
expected_text = to_expected_text_values (
@@ -526,6 +543,7 @@ async def to_have_text(
526
543
),
527
544
expected ,
528
545
"Locator expected to have text" ,
546
+ 'Expect "to_have_text"' ,
529
547
)
530
548
531
549
async def not_to_have_text (
@@ -558,6 +576,7 @@ async def to_be_attached(
558
576
FrameExpectOptions (timeout = timeout ),
559
577
None ,
560
578
f"Locator expected to be { attached_string } " ,
579
+ 'Expect "to_be_attached"' ,
561
580
)
562
581
563
582
async def to_be_checked (
@@ -582,6 +601,7 @@ async def to_be_checked(
582
601
FrameExpectOptions (timeout = timeout , expectedValue = expected_value ),
583
602
None ,
584
603
f"Locator expected to be { checked_string } " ,
604
+ 'Expect "to_be_checked"' ,
585
605
)
586
606
587
607
async def not_to_be_attached (
@@ -609,6 +629,7 @@ async def to_be_disabled(
609
629
FrameExpectOptions (timeout = timeout ),
610
630
None ,
611
631
"Locator expected to be disabled" ,
632
+ 'Expect "to_be_disabled"' ,
612
633
)
613
634
614
635
async def not_to_be_disabled (
@@ -632,6 +653,7 @@ async def to_be_editable(
632
653
FrameExpectOptions (timeout = timeout ),
633
654
None ,
634
655
f"Locator expected to be { editable_string } " ,
656
+ 'Expect "to_be_editable"' ,
635
657
)
636
658
637
659
async def not_to_be_editable (
@@ -652,6 +674,7 @@ async def to_be_empty(
652
674
FrameExpectOptions (timeout = timeout ),
653
675
None ,
654
676
"Locator expected to be empty" ,
677
+ 'Expect "to_be_empty"' ,
655
678
)
656
679
657
680
async def not_to_be_empty (
@@ -675,6 +698,7 @@ async def to_be_enabled(
675
698
FrameExpectOptions (timeout = timeout ),
676
699
None ,
677
700
f"Locator expected to be { enabled_string } " ,
701
+ 'Expect "to_be_enabled"' ,
678
702
)
679
703
680
704
async def not_to_be_enabled (
@@ -695,6 +719,7 @@ async def to_be_hidden(
695
719
FrameExpectOptions (timeout = timeout ),
696
720
None ,
697
721
"Locator expected to be hidden" ,
722
+ 'Expect "to_be_hidden"' ,
698
723
)
699
724
700
725
async def not_to_be_hidden (
@@ -718,6 +743,7 @@ async def to_be_visible(
718
743
FrameExpectOptions (timeout = timeout ),
719
744
None ,
720
745
f"Locator expected to be { visible_string } " ,
746
+ 'Expect "to_be_visible"' ,
721
747
)
722
748
723
749
async def not_to_be_visible (
@@ -738,6 +764,7 @@ async def to_be_focused(
738
764
FrameExpectOptions (timeout = timeout ),
739
765
None ,
740
766
"Locator expected to be focused" ,
767
+ 'Expect "to_be_focused"' ,
741
768
)
742
769
743
770
async def not_to_be_focused (
@@ -758,6 +785,7 @@ async def to_be_in_viewport(
758
785
FrameExpectOptions (timeout = timeout , expectedNumber = ratio ),
759
786
None ,
760
787
"Locator expected to be in viewport" ,
788
+ 'Expect "to_be_in_viewport"' ,
761
789
)
762
790
763
791
async def not_to_be_in_viewport (
@@ -781,6 +809,7 @@ async def to_have_accessible_description(
781
809
FrameExpectOptions (expectedText = expected_values , timeout = timeout ),
782
810
None ,
783
811
"Locator expected to have accessible description" ,
812
+ 'Expect "to_have_accessible_description"' ,
784
813
)
785
814
786
815
async def not_to_have_accessible_description (
@@ -807,6 +836,7 @@ async def to_have_accessible_name(
807
836
FrameExpectOptions (expectedText = expected_values , timeout = timeout ),
808
837
None ,
809
838
"Locator expected to have accessible name" ,
839
+ 'Expect "to_have_accessible_name"' ,
810
840
)
811
841
812
842
async def not_to_have_accessible_name (
@@ -828,6 +858,7 @@ async def to_have_role(self, role: AriaRole, timeout: float = None) -> None:
828
858
FrameExpectOptions (expectedText = expected_values , timeout = timeout ),
829
859
None ,
830
860
"Locator expected to have accessible role" ,
861
+ 'Expect "to_have_role"' ,
831
862
)
832
863
833
864
async def to_have_accessible_error_message (
@@ -845,6 +876,7 @@ async def to_have_accessible_error_message(
845
876
FrameExpectOptions (expectedText = expected_values , timeout = timeout ),
846
877
None ,
847
878
"Locator expected to have accessible error message" ,
879
+ 'Expect "to_have_accessible_error_message"' ,
848
880
)
849
881
850
882
async def not_to_have_accessible_error_message (
@@ -871,6 +903,7 @@ async def to_match_aria_snapshot(
871
903
FrameExpectOptions (expectedValue = expected , timeout = timeout ),
872
904
expected ,
873
905
"Locator expected to match Aria snapshot" ,
906
+ 'Expect "to_match_aria_snapshot"' ,
874
907
)
875
908
876
909
async def not_to_match_aria_snapshot (
0 commit comments