20
20
AriaRole ,
21
21
ExpectedTextValue ,
22
22
FrameExpectOptions ,
23
+ FrameExpectResult ,
23
24
)
24
25
from playwright ._impl ._connection import format_call_log
25
26
from playwright ._impl ._errors import Error
@@ -45,6 +46,13 @@ def __init__(
45
46
self ._is_not = is_not
46
47
self ._custom_message = message
47
48
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
+
48
56
async def _expect_impl (
49
57
self ,
50
58
expression : str ,
@@ -61,7 +69,7 @@ async def _expect_impl(
61
69
message = message .replace ("expected to" , "expected not to" )
62
70
if "useInnerText" in expect_options and expect_options ["useInnerText" ] is None :
63
71
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 )
65
73
if result ["matches" ] == self ._is_not :
66
74
actual = result .get ("received" )
67
75
if self ._custom_message :
@@ -88,6 +96,14 @@ def __init__(
88
96
super ().__init__ (page .locator (":root" ), timeout , is_not , message )
89
97
self ._actual_page = page
90
98
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
+
91
107
@property
92
108
def _not (self ) -> "PageAssertions" :
93
109
return PageAssertions (
@@ -122,7 +138,7 @@ async def to_have_url(
122
138
ignoreCase : bool = None ,
123
139
) -> None :
124
140
__tracebackhide__ = True
125
- base_url = self ._actual_page .context ._options . get ( "baseURL" )
141
+ base_url = self ._actual_page .context ._base_url
126
142
if isinstance (urlOrRegExp , str ) and base_url :
127
143
urlOrRegExp = urljoin (base_url , urlOrRegExp )
128
144
expected_text = to_expected_text_values ([urlOrRegExp ], ignoreCase = ignoreCase )
@@ -155,6 +171,12 @@ def __init__(
155
171
super ().__init__ (locator , timeout , is_not , message )
156
172
self ._actual_locator = locator
157
173
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
+
158
180
@property
159
181
def _not (self ) -> "LocatorAssertions" :
160
182
return LocatorAssertions (
0 commit comments