MCPcopy Index your code
hub / github.com/microsoft/playwright-python / _expect_impl

Method _expect_impl

playwright/_impl/_assertions.py:87–131  ·  view source on GitHub ↗
(
        self,
        expression: str,
        expect_options: FrameExpectOptions,
        expected: Any,
        message: str,
        title: str = None,
    )

Source from the content-addressed store, hash-verified

85 )
86
87 async def _expect_impl(
88 self,
89 expression: str,
90 expect_options: FrameExpectOptions,
91 expected: Any,
92 message: str,
93 title: str = None,
94 ) -> None:
95 __tracebackhide__ = True
96 expect_options["isNot"] = self._is_not
97 if expect_options.get("timeout") is None:
98 expect_options["timeout"] = self._timeout or 5_000
99 if expect_options["isNot"]:
100 message = message.replace("expected to", "expected not to")
101 if "useInnerText" in expect_options and expect_options["useInnerText"] is None:
102 del expect_options["useInnerText"]
103 result = await self._call_expect(expression, expect_options, title)
104 if result["matches"] == self._is_not:
105 received = result.get("received") or {}
106 aria_snapshot = None
107 if isinstance(received, dict):
108 aria_snapshot = received.get("ariaSnapshot")
109 value = received.get("value")
110 actual = parse_value(value) if value is not None else None
111 else:
112 actual = received
113 if self._custom_message:
114 out_message = self._custom_message
115 if expected is not None:
116 out_message += f"\nExpected value: '{expected or '<None>'}'"
117 else:
118 out_message = (
119 f"{message} '{expected}'" if expected is not None else f"{message}"
120 )
121 error_message = result.get("errorMessage")
122 error_message = f"\n{error_message}" if error_message else ""
123 aria_snapshot_message = (
124 f"\nAria snapshot:\n{aria_snapshot}" if aria_snapshot else ""
125 )
126 _record_soft_or_raise(
127 AssertionError(
128 f"{out_message}\nActual value: {actual}{error_message} {format_call_log(result.get('log'))}{aria_snapshot_message}"
129 ),
130 self._is_soft,
131 )
132
133
134class PageAssertions(AssertionsBase):

Callers 15

to_have_titleMethod · 0.80
to_have_urlMethod · 0.80
to_contain_textMethod · 0.80
to_have_attributeMethod · 0.80
to_have_classMethod · 0.80
to_contain_classMethod · 0.80
to_have_countMethod · 0.80
to_have_cssMethod · 0.80
to_have_idMethod · 0.80
to_have_js_propertyMethod · 0.80
to_have_valueMethod · 0.80

Calls 5

_call_expectMethod · 0.95
parse_valueFunction · 0.90
format_call_logFunction · 0.90
_record_soft_or_raiseFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected