> For the complete documentation index, see [llms.txt](https://docs.gpmautomate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gpmautomate.com/automate-en/action-guides/mouse/mouse-click-try.md).

# Mouse try to click

Mouse try to click is an advanced action of the mouse command group, allowing the script to repeatedly perform a click action on a target until a desired condition is met, at which point it will stop.

This action is the perfect solution for handling "stubborn" buttons on websites (types of buttons that may lag and require several preliminary clicks to register the command), or to spam reward buttons or gift box opening buttons that appear for a short time.

#### Core configuration parameters:

* Click type: Similar to the Mouse click action, you also have 3 types of options to specify the click position:
  1. *Click based on XPath*: The system finds the HTML tag of the element to click on.
  2. *Click based on the current mouse pointer position*: Continuously click at the point where the mouse pointer is stationary.
  3. *Click based on coordinates*: Click on a fixed pixel point or pass a variable combining coordinates in the format `900,800` (combined from the result of the *Image search* action).
* Number of tries: The maximum number of click attempts that the script is allowed to perform (For example, entering `10`, the system will click a maximum of 10 times and then automatically stop the flow to move on to the next action, avoiding the script hanging indefinitely).
* Delay each clicks (s): The time interval between two consecutive clicks, measured in seconds (For example, entering `0.5` or `1` second to prevent the mouse from clicking too quickly, causing the system to misunderstand it as spam/DDoS).
* Stop condition: The condition for the system to issue an immediate stop click command. The mouse will continuously click until this condition is met OR until the specified number of times in the *Number of tries* section has been clicked.

#### Practical example: Continuously click on the "Receive OTP code" button until the code input box appears

When you register an account on websites with slow loading systems, when clicking the "Send Code" button, the system may become congested and not respond immediately. You need the mouse to click continuously until an OTP input box appears on the screen before stopping.

* Configuration:
  * Click type: Select *Click based on XPath* ➔ Enter the XPath of the send code button: `//button[@id="send-code"]`.
  * Number of tries: Enter `5` (try a maximum of 5 times).
  * Delay each clicks: Enter `2` (each click is spaced 2 seconds apart to wait for the website to process).
  * Stop condition: Use the function to check if the element appears: `hasElement(//input[@id="otp-input"])`.

Operational logic: The system moves the mouse to the send code button and clicks for the first time. After 2 seconds, the system checks if the OTP input box (`//input[@id="otp-input"]`) has appeared. If not, the system continues to click for the second, third time... As soon as it clicks for the third time, the system responds, and the OTP input box appears on the screen (the `hasElement` function returns true), the script will immediately stop this click action and move on to the next step without needing to click the remaining 2 times.

> 💡 Expansion tip: You can also use the negation condition `!hasElement(XPATH)` to command the mouse to click continuously until an advertisement banner or a loading circle icon disappears from the screen.

<figure><img src="/files/VoJa88HNxJho7kGMBj84" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.gpmautomate.com/automate-en/action-guides/mouse/mouse-click-try.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
