# How to Generate a Random Number Within a Given Range

You can use the following JavaScript expression to generate a random integer within a specified range, including both the minimum and maximum values:

```
var $randomnumber = Math.floor(Math.random() * ($maximum - $minimum + 1)) + $minimum;
```

For example, the following code generates a random integer between `<span class="editor-theme-code">3</span>` and `<span class="editor-theme-code">7</span>`:

```
var $randomnumber = Math.floor(Math.random() * (7 - 3 + 1)) + 3;
```

The generated value can be `<span class="editor-theme-code">3</span>`, `<span class="editor-theme-code">4</span>`, `<span class="editor-theme-code">5</span>`, `<span class="editor-theme-code">6</span>`, or `<span class="editor-theme-code">7</span>`.

The random value can then be used in a Test Designer action. For example:

```
_highlight(_link($randomnumber, _near(_span("Smart Account"))))
```

This approach is useful when test scripts need to select or interact with different values dynamically during execution.

---

Last updated: August 21, 2026

If you have any feedback on this topic, please contact us at <documentation@appvance.ai>