Skip to main content
Web automation requires careful timing. Pages load at different speeds, elements appear dynamically, and networks can be slow.

Timing Controls

Sleep Times

before_sleep_time

Wait before executing the action. Use when page needs to load or settle.

end_sleep_time

Wait after action completes. Use when subsequent actions depend on this action’s effects.

Default Values

Sleep times must be between 0 and 10 seconds.

Automation-Level Retries

max_retries on the automation reruns the entire automation when an unexpected error occurs (e.g. browser crash, network failure).
AssertionError failures (e.g. failed assertions) are never retried regardless of max_retries. Retries only apply to unexpected runtime errors.

Element-Level Retry Configuration

Control how Optexity retries finding elements.

How Retries Work

  1. Attempt to find element using command or xpath
  2. If not found within timeout, retry
  3. After all tries exhausted, use AI with prompt_instructions
  4. If AI can’t find it, action fails
Increase max_tries rather than timeout per try. This finds elements faster when they appear while still handling slow pages.

Handling New Tabs

expect_new_tab

Set when action opens a new browser tab:
When expect_new_tab=True:
  • max_new_tab_wait_time automatically set to 10.0
  • Automation waits for new tab
  • Focus switches to new tab

Common Patterns

Slow-Loading Pages

Dynamic AJAX Content

Optional Elements


Troubleshooting


Best Practices