2020    AriaRole ,
2121    ExpectedTextValue ,
2222    FrameExpectOptions ,
23+     FrameExpectResult ,
2324)
2425from  playwright ._impl ._connection  import  format_call_log 
2526from  playwright ._impl ._errors  import  Error 
@@ -45,6 +46,13 @@ def __init__(
4546        self ._is_not  =  is_not 
4647        self ._custom_message  =  message 
4748
49+     async  def  _call_expect (
50+         self , expression : str , expect_options : FrameExpectOptions , title : Optional [str ]
51+     ) ->  FrameExpectResult :
52+         raise  NotImplementedError (
53+             "_call_expect must be implemented in a derived class." 
54+         )
55+ 
4856    async  def  _expect_impl (
4957        self ,
5058        expression : str ,
@@ -61,7 +69,7 @@ async def _expect_impl(
6169            message  =  message .replace ("expected to" , "expected not to" )
6270        if  "useInnerText"  in  expect_options  and  expect_options ["useInnerText" ] is  None :
6371            del  expect_options ["useInnerText" ]
64-         result  =  await  self ._actual_locator . _expect (expression , expect_options , title )
72+         result  =  await  self ._call_expect (expression , expect_options , title )
6573        if  result ["matches" ] ==  self ._is_not :
6674            actual  =  result .get ("received" )
6775            if  self ._custom_message :
@@ -88,6 +96,14 @@ def __init__(
8896        super ().__init__ (page .locator (":root" ), timeout , is_not , message )
8997        self ._actual_page  =  page 
9098
99+     async  def  _call_expect (
100+         self , expression : str , expect_options : FrameExpectOptions , title : Optional [str ]
101+     ) ->  FrameExpectResult :
102+         __tracebackhide__  =  True 
103+         return  await  self ._actual_page .main_frame ._expect (
104+             None , expression , expect_options , title 
105+         )
106+ 
91107    @property  
92108    def  _not (self ) ->  "PageAssertions" :
93109        return  PageAssertions (
@@ -122,7 +138,7 @@ async def to_have_url(
122138        ignoreCase : bool  =  None ,
123139    ) ->  None :
124140        __tracebackhide__  =  True 
125-         base_url  =  self ._actual_page .context ._options . get ( "baseURL" ) 
141+         base_url  =  self ._actual_page .context ._base_url 
126142        if  isinstance (urlOrRegExp , str ) and  base_url :
127143            urlOrRegExp  =  urljoin (base_url , urlOrRegExp )
128144        expected_text  =  to_expected_text_values ([urlOrRegExp ], ignoreCase = ignoreCase )
@@ -155,6 +171,12 @@ def __init__(
155171        super ().__init__ (locator , timeout , is_not , message )
156172        self ._actual_locator  =  locator 
157173
174+     async  def  _call_expect (
175+         self , expression : str , expect_options : FrameExpectOptions , title : Optional [str ]
176+     ) ->  FrameExpectResult :
177+         __tracebackhide__  =  True 
178+         return  await  self ._actual_locator ._expect (expression , expect_options , title )
179+ 
158180    @property  
159181    def  _not (self ) ->  "LocatorAssertions" :
160182        return  LocatorAssertions (
0 commit comments