16
16
from typing import Any , List , Optional , Pattern , Sequence , Union
17
17
from urllib .parse import urljoin
18
18
19
- from playwright ._impl ._api_structures import ExpectedTextValue , FrameExpectOptions
19
+ from playwright ._impl ._api_structures import (
20
+ AriaRole ,
21
+ ExpectedTextValue ,
22
+ FrameExpectOptions ,
23
+ )
20
24
from playwright ._impl ._connection import format_call_log
21
25
from playwright ._impl ._errors import Error
22
26
from playwright ._impl ._fetch import APIResponse
@@ -92,10 +96,10 @@ def _not(self) -> "PageAssertions":
92
96
async def to_have_title (
93
97
self , titleOrRegExp : Union [Pattern [str ], str ], timeout : float = None
94
98
) -> None :
99
+ __tracebackhide__ = True
95
100
expected_values = to_expected_text_values (
96
101
[titleOrRegExp ], normalize_white_space = True
97
102
)
98
- __tracebackhide__ = True
99
103
await self ._expect_impl (
100
104
"to.have.title" ,
101
105
FrameExpectOptions (expectedText = expected_values , timeout = timeout ),
@@ -110,13 +114,16 @@ async def not_to_have_title(
110
114
await self ._not .to_have_title (titleOrRegExp , timeout )
111
115
112
116
async def to_have_url (
113
- self , urlOrRegExp : Union [str , Pattern [str ]], timeout : float = None
117
+ self ,
118
+ urlOrRegExp : Union [str , Pattern [str ]],
119
+ timeout : float = None ,
120
+ ignoreCase : bool = None ,
114
121
) -> None :
115
122
__tracebackhide__ = True
116
123
base_url = self ._actual_page .context ._options .get ("baseURL" )
117
124
if isinstance (urlOrRegExp , str ) and base_url :
118
125
urlOrRegExp = urljoin (base_url , urlOrRegExp )
119
- expected_text = to_expected_text_values ([urlOrRegExp ])
126
+ expected_text = to_expected_text_values ([urlOrRegExp ], ignoreCase = ignoreCase )
120
127
await self ._expect_impl (
121
128
"to.have.url" ,
122
129
FrameExpectOptions (expectedText = expected_text , timeout = timeout ),
@@ -125,10 +132,13 @@ async def to_have_url(
125
132
)
126
133
127
134
async def not_to_have_url (
128
- self , urlOrRegExp : Union [Pattern [str ], str ], timeout : float = None
135
+ self ,
136
+ urlOrRegExp : Union [Pattern [str ], str ],
137
+ timeout : float = None ,
138
+ ignoreCase : bool = None ,
129
139
) -> None :
130
140
__tracebackhide__ = True
131
- await self ._not .to_have_url (urlOrRegExp , timeout )
141
+ await self ._not .to_have_url (urlOrRegExp , timeout , ignoreCase )
132
142
133
143
134
144
class LocatorAssertions (AssertionsBase ):
@@ -704,6 +714,70 @@ async def not_to_be_in_viewport(
704
714
__tracebackhide__ = True
705
715
await self ._not .to_be_in_viewport (ratio = ratio , timeout = timeout )
706
716
717
+ async def to_have_accessible_description (
718
+ self ,
719
+ description : Union [str , Pattern [str ]],
720
+ ignoreCase : bool = None ,
721
+ timeout : float = None ,
722
+ ) -> None :
723
+ __tracebackhide__ = True
724
+ expected_values = to_expected_text_values ([description ], ignoreCase = ignoreCase )
725
+ await self ._expect_impl (
726
+ "to.have.accessible.description" ,
727
+ FrameExpectOptions (expectedText = expected_values , timeout = timeout ),
728
+ None ,
729
+ "Locator expected to have accessible description" ,
730
+ )
731
+
732
+ async def not_to_have_accessible_description (
733
+ self ,
734
+ name : Union [str , Pattern [str ]],
735
+ ignoreCase : bool = None ,
736
+ timeout : float = None ,
737
+ ) -> None :
738
+ __tracebackhide__ = True
739
+ await self ._not .to_have_accessible_description (name , ignoreCase , timeout )
740
+
741
+ async def to_have_accessible_name (
742
+ self ,
743
+ name : Union [str , Pattern [str ]],
744
+ ignoreCase : bool = None ,
745
+ timeout : float = None ,
746
+ ) -> None :
747
+ __tracebackhide__ = True
748
+ expected_values = to_expected_text_values ([name ], ignoreCase = ignoreCase )
749
+ await self ._expect_impl (
750
+ "to.have.accessible.name" ,
751
+ FrameExpectOptions (expectedText = expected_values , timeout = timeout ),
752
+ None ,
753
+ "Locator expected to have accessible name" ,
754
+ )
755
+
756
+ async def not_to_have_accessible_name (
757
+ self ,
758
+ name : Union [str , Pattern [str ]],
759
+ ignoreCase : bool = None ,
760
+ timeout : float = None ,
761
+ ) -> None :
762
+ __tracebackhide__ = True
763
+ await self ._not .to_have_accessible_name (name , ignoreCase , timeout )
764
+
765
+ async def to_have_role (self , role : AriaRole , timeout : float = None ) -> None :
766
+ __tracebackhide__ = True
767
+ if isinstance (role , Pattern ):
768
+ raise Error ('"role" argument in to_have_role must be a string' )
769
+ expected_values = to_expected_text_values ([role ])
770
+ await self ._expect_impl (
771
+ "to.have.role" ,
772
+ FrameExpectOptions (expectedText = expected_values , timeout = timeout ),
773
+ None ,
774
+ "Locator expected to have accessible role" ,
775
+ )
776
+
777
+ async def not_to_have_role (self , role : AriaRole , timeout : float = None ) -> None :
778
+ __tracebackhide__ = True
779
+ await self ._not .to_have_role (role , timeout )
780
+
707
781
708
782
class APIResponseAssertions :
709
783
def __init__ (
0 commit comments