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

Method tap

playwright/async_api/_generated.py:19937–20001  ·  view source on GitHub ↗

Locator.tap Perform a tap gesture on the element matching the locator. For examples of emulating other gestures by manually dispatching touch events, see the [emulating legacy touch events](https://playwright.dev/python/docs/touch-events) page. **Details** This met

(
        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

19935 )
19936
19937 async def tap(
19938 self,
19939 *,
19940 modifiers: typing.Optional[
19941 typing.Sequence[Literal["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]]
19942 ] = None,
19943 position: typing.Optional[Position] = None,
19944 timeout: typing.Optional[typing.Union[float, datetime.timedelta]] = None,
19945 force: typing.Optional[bool] = None,
19946 no_wait_after: typing.Optional[bool] = None,
19947 trial: typing.Optional[bool] = None,
19948 ) -> None:
19949 """Locator.tap
19950
19951 Perform a tap gesture on the element matching the locator. For examples of emulating other gestures by manually
19952 dispatching touch events, see the [emulating legacy touch events](https://playwright.dev/python/docs/touch-events) page.
19953
19954 **Details**
19955
19956 This method taps the element by performing the following steps:
19957 1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
19958 1. Scroll the element into view if needed.
19959 1. Use `page.touchscreen` to tap the center of the element, or the specified `position`.
19960
19961 If the element is detached from the DOM at any moment during the action, this method throws.
19962
19963 When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`.
19964 Passing zero timeout disables this.
19965
19966 **NOTE** `element.tap()` requires that the `hasTouch` option of the browser context be set to true.
19967
19968 Parameters
19969 ----------
19970 modifiers : Union[Sequence[Union["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]], None]
19971 Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores
19972 current modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to
19973 "Control" on Windows and Linux and to "Meta" on macOS.
19974 position : Union[{x: float, y: float}, None]
19975 A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of
19976 the element.
19977 timeout : Union[float, None]
19978 Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can
19979 be changed by using the `browser_context.set_default_timeout()` or `page.set_default_timeout()` methods.
19980 force : Union[bool, None]
19981 Whether to bypass the [actionability](../actionability.md) checks. Defaults to `false`.
19982 no_wait_after : Union[bool, None]
19983 This option has no effect.
19984 Deprecated: This option has no effect.
19985 trial : Union[bool, None]
19986 When set, this method only performs the [actionability](../actionability.md) checks and skips the action. Defaults
19987 to `false`. Useful to wait until the element is ready for the action without performing it. Note that keyboard
19988 `modifiers` will be pressed regardless of `trial` to allow testing elements which are only visible when those keys
19989 are pressed.
19990 """
19991
19992 return mapping.from_maybe_impl(
19993 await self._impl_obj.tap(
19994 modifiers=mapping.to_impl(modifiers),

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