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

Method click

playwright/async_api/_generated.py:17607–17704  ·  view source on GitHub ↗

Locator.click Click an element. **Details** This method clicks 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 el

(
        self,
        *,
        modifiers: typing.Optional[
            typing.Sequence[Literal["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]]
        ] = None,
        position: typing.Optional[Position] = None,
        delay: typing.Optional[float] = None,
        button: typing.Optional[Literal["left", "middle", "right"]] = None,
        click_count: typing.Optional[int] = 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,
        steps: typing.Optional[int] = None,
    )

Source from the content-addressed store, hash-verified

17605 )
17606
17607 async def click(
17608 self,
17609 *,
17610 modifiers: typing.Optional[
17611 typing.Sequence[Literal["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]]
17612 ] = None,
17613 position: typing.Optional[Position] = None,
17614 delay: typing.Optional[float] = None,
17615 button: typing.Optional[Literal["left", "middle", "right"]] = None,
17616 click_count: typing.Optional[int] = None,
17617 timeout: typing.Optional[typing.Union[float, datetime.timedelta]] = None,
17618 force: typing.Optional[bool] = None,
17619 no_wait_after: typing.Optional[bool] = None,
17620 trial: typing.Optional[bool] = None,
17621 steps: typing.Optional[int] = None,
17622 ) -> None:
17623 """Locator.click
17624
17625 Click an element.
17626
17627 **Details**
17628
17629 This method clicks the element by performing the following steps:
17630 1. Wait for [actionability](https://playwright.dev/python/docs/actionability) checks on the element, unless `force` option is set.
17631 1. Scroll the element into view if needed.
17632 1. Use `page.mouse` to click in the center of the element, or the specified `position`.
17633 1. Wait for initiated navigations to either succeed or fail, unless `noWaitAfter` option is set.
17634
17635 If the element is detached from the DOM at any moment during the action, this method throws.
17636
17637 When all steps combined have not finished during the specified `timeout`, this method throws a `TimeoutError`.
17638 Passing zero timeout disables this.
17639
17640 **Usage**
17641
17642 Click a button:
17643
17644 ```py
17645 await page.get_by_role(\"button\").click()
17646 ```
17647
17648 Shift-right-click at a specific position on a canvas:
17649
17650 ```py
17651 await page.locator(\"canvas\").click(
17652 button=\"right\", modifiers=[\"Shift\"], position={\"x\": 23, \"y\": 32}
17653 )
17654 ```
17655
17656 Parameters
17657 ----------
17658 modifiers : Union[Sequence[Union["Alt", "Control", "ControlOrMeta", "Meta", "Shift"]], None]
17659 Modifier keys to press. Ensures that only these modifiers are pressed during the operation, and then restores
17660 current modifiers back. If not specified, currently pressed modifiers are used. "ControlOrMeta" resolves to
17661 "Control" on Windows and Linux and to "Meta" on macOS.
17662 position : Union[{x: float, y: float}, None]
17663 A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of
17664 the element.

Callers

nothing calls this directly

Calls 4

to_millisecondsFunction · 0.90
from_maybe_implMethod · 0.80
to_implMethod · 0.80
clickMethod · 0.45

Tested by

no test coverage detected