MCPcopy
hub / github.com/microsoft/playwright-python / tap

Method tap

playwright/async_api/_generated.py:2495–2552  ·  view source on GitHub ↗

ElementHandle.tap This method taps the element by performing the following steps: 1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set. 1. Scroll the element into view if needed. 1. Use `pag

(
        self,
        *,
        modifiers: typing.Optional[
            typing.Sequence[Literal["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]]
        ] = None,
        position: typing.Optional[Position] = None,
        timeout: typing.Optional[typing.Union[float, datetime.timedelta]] = None,
        force: typing.Optional[bool] = None,
        no_wait_after: typing.Optional[bool] = None,
        trial: typing.Optional[bool] = None,
    )

Source from the content-addressed store, hash-verified

2493 )
2494
2495 async def tap(
2496 self,
2497 *,
2498 modifiers: typing.Optional[
2499 typing.Sequence[Literal["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]]
2500 ] = None,
2501 position: typing.Optional[Position] = None,
2502 timeout: typing.Optional[typing.Union[float, datetime.timedelta]] = None,
2503 force: typing.Optional[bool] = None,
2504 no_wait_after: typing.Optional[bool] = None,
2505 trial: typing.Optional[bool] = None,
2506 ) -> None:
2507 """ElementHandle.tap
2508
2509 This method taps the element by performing the following steps:
2510 1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
2511 1. Scroll the element into view if needed.
2512 1. Use `page.touchscreen` to tap the center of the element, or the specified `position`.
2513
2514 If the element is detached from the DOM at any moment during the action, this method throws.
2515
2516 When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`.
2517 Passing zero timeout disables this.
2518
2519 **NOTE** `elementHandle.tap()` requires that the `hasTouch` option of the browser context be set to true.
2520
2521 Parameters
2522 ----------
2523 modifiers : Union[Sequence[Union["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]], None]
2524 Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores
2525 current modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to
2526 "Control" on Windows and Linux and to "Meta" on macOS.
2527 position : Union[{x: float, y: float}, None]
2528 A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of
2529 the element.
2530 timeout : Union[float, None]
2531 Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can
2532 be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods.
2533 force : Union[bool, None]
2534 Whether to bypass the [actionability](../actionability.md) checks. Defaults to `false`.
2535 no_wait_after : Union[bool, None]
2536 This option has no effect.
2537 Deprecated: This option has no effect.
2538 trial : Union[bool, None]
2539 When set, this method only performs the [actionability](../actionability.md) checks and skips the action. Defaults
2540 to `false`. Useful to wait until the element is ready for the action without performing it.
2541 """
2542
2543 return mapping.from_maybe_impl(
2544 await self._impl_obj.tap(
2545 modifiers=mapping.to_impl(modifiers),
2546 position=position,
2547 timeout=to_milliseconds(timeout),
2548 force=force,
2549 noWaitAfter=no_wait_after,
2550 trial=trial,
2551 )
2552 )

Callers

nothing calls this directly

Calls 4

to_millisecondsFunction · 0.90
from_maybe_implMethod · 0.80
to_implMethod · 0.80
tapMethod · 0.45

Tested by

no test coverage detected