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

Method _with_element

playwright/_impl/_locator.py:107–123  ·  view source on GitHub ↗
(
        self,
        task: Callable[[ElementHandle, float], Awaitable[T]],
        timeout: float = None,
    )

Source from the content-addressed store, hash-verified

105 return f"<Locator frame={self._frame!r} selector={self._selector!r}>"
106
107 async def _with_element(
108 self,
109 task: Callable[[ElementHandle, float], Awaitable[T]],
110 timeout: float = None,
111 ) -> T:
112 timeout = self._frame._timeout(timeout)
113 deadline = (monotonic_time() + timeout) if timeout else 0
114 handle = await self.element_handle(timeout=timeout)
115 if not handle:
116 raise Error(f"Could not resolve {self._selector} to DOM Element")
117 try:
118 return await task(
119 handle,
120 (deadline - monotonic_time()) if deadline else 0,
121 )
122 finally:
123 await handle.dispose()
124
125 def _equals(self, locator: "Locator") -> bool:
126 return self._frame == locator._frame and self._selector == locator._selector

Callers 6

bounding_boxMethod · 0.95
evaluateMethod · 0.95
evaluate_handleMethod · 0.95
screenshotMethod · 0.95
select_textMethod · 0.95

Calls 6

element_handleMethod · 0.95
monotonic_timeFunction · 0.90
ErrorClass · 0.85
taskFunction · 0.85
_timeoutMethod · 0.80
disposeMethod · 0.45

Tested by

no test coverage detected