1616from typing import Any , List , Optional , Pattern , Sequence , Union
1717from urllib .parse import urljoin
1818
19- from playwright ._impl ._api_structures import ExpectedTextValue , FrameExpectOptions
19+ from playwright ._impl ._api_structures import (
20+ AriaRole ,
21+ ExpectedTextValue ,
22+ FrameExpectOptions ,
23+ )
2024from playwright ._impl ._connection import format_call_log
2125from playwright ._impl ._errors import Error
2226from playwright ._impl ._fetch import APIResponse
@@ -92,10 +96,10 @@ def _not(self) -> "PageAssertions":
9296 async def to_have_title (
9397 self , titleOrRegExp : Union [Pattern [str ], str ], timeout : float = None
9498 ) -> None :
99+ __tracebackhide__ = True
95100 expected_values = to_expected_text_values (
96101 [titleOrRegExp ], normalize_white_space = True
97102 )
98- __tracebackhide__ = True
99103 await self ._expect_impl (
100104 "to.have.title" ,
101105 FrameExpectOptions (expectedText = expected_values , timeout = timeout ),
@@ -110,13 +114,16 @@ async def not_to_have_title(
110114 await self ._not .to_have_title (titleOrRegExp , timeout )
111115
112116 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 ,
114121 ) -> None :
115122 __tracebackhide__ = True
116123 base_url = self ._actual_page .context ._options .get ("baseURL" )
117124 if isinstance (urlOrRegExp , str ) and base_url :
118125 urlOrRegExp = urljoin (base_url , urlOrRegExp )
119- expected_text = to_expected_text_values ([urlOrRegExp ])
126+ expected_text = to_expected_text_values ([urlOrRegExp ], ignoreCase = ignoreCase )
120127 await self ._expect_impl (
121128 "to.have.url" ,
122129 FrameExpectOptions (expectedText = expected_text , timeout = timeout ),
@@ -125,10 +132,13 @@ async def to_have_url(
125132 )
126133
127134 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 ,
129139 ) -> None :
130140 __tracebackhide__ = True
131- await self ._not .to_have_url (urlOrRegExp , timeout )
141+ await self ._not .to_have_url (urlOrRegExp , timeout , ignoreCase )
132142
133143
134144class LocatorAssertions (AssertionsBase ):
@@ -704,6 +714,70 @@ async def not_to_be_in_viewport(
704714 __tracebackhide__ = True
705715 await self ._not .to_be_in_viewport (ratio = ratio , timeout = timeout )
706716
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+
707781
708782class APIResponseAssertions :
709783 def __init__ (
0 commit comments