> 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/blocks/writing-conditions.md).

# Guide to writing Conditions

> ⚠️ Core rule for Strings: For data types that are strings, you must wrap them in double quotes `""` (e.g., `$name = "admin"`). For numbers, enter them directly.

#### 1. Arithmetic Comparison Operators (Applicable only to Numbers)

* `>` : Greater than. (Example: `$count > 5`)
* `<` : Less than. (Example: `$loopIndex < 10`)
* `>=` : Greater than or equal to.
* `<=` : Less than or equal to.

#### 2. Logical Comparison Operators (Applicable to both Numbers and Strings)

* `=` : Equal.
  * *Example*: `3 = 3` ➡️ `true`
  * *Example*: `"hello" = "hola"` ➡️ `false`
* `!=` : Not equal (Negation of equality).
  * *Example*: `3 != 4` ➡️ `true`
  * *Example*: `"hello" != "hello"` ➡️ `false`

#### 3. String Processing Operators

* `contains` : Checks if the preceding string contains the following string.
  * *Example*: `"ABCD" contains "AB"` ➡️ `true`
  * *Example*: `"AB" contains "ABCD"` ➡️ `false`
* `!contains` : Checks if the preceding string does NOT contain the following string.
  * *Example*: `!"ABCD" contains "AB"` ➡️ `false`
  * *Example*: `!"AB" contains "ABCD"` ➡️ `true`
* `contains "B"` (When standing alone before B): Checks if the variable or string being examined is an empty string.
  * *Result*: Returns `true` if empty, and `false` if it contains data.

#### 4. Function to Check Element on the Interface

This function helps the script identify the presence of buttons, input fields, etc., on the webpage through the XPath:

* `hasElement(XPATH)` : Condition is true when the element exists on the page.
* `!hasElement(XPATH)` : Condition is true when the element does not exist on the page (Negation of `hasElement`).

#### 5. How to Combine Multiple Complex Conditions

You can combine multiple conditions in one line using logical symbols and parentheses `()` to group them:

* `&&` : AND (All conditions must be true simultaneously).
* `||` : OR (Only one of the conditions needs to be true).

Practical examples when writing conditions:

* *Case 1*: Check if the number of iterations is greater than 5 and the account name contains the string "abc":

  ```
  $count > 5 && $name contains "abc"
  ```
* *Case 2*: Check if the Login button does not appear (logged in) OR the error variable is displaying the string "true":

  ```
  !hasElement(//div[@id='x']) || $error = "true"
  ```


---

# 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/blocks/writing-conditions.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.
