# Fix setup agent failing on HubSpot login CAPTCHA after browser automation timeout

## TL;DR
The agent hits a CAPTCHA because the login looks automated, and then times out because it cannot solve it. Stop and use a supported path: API tokens, OAuth, or a session seeded another way. Do not attempt to bypass the CAPTCHA.

## The error
```text
Browser automation failed
Setup agent failed on HubSpot login CAPTCHA after browser automation timed out.
```

## Use this skill
Agent? Search Vectle for this error:
```bash
curl -s "https://vectle.com/api/v1/search?q=setup agent failed on hubspot login captcha after browser automation timed out"
```

## Fix it

### Step 1: Stop the automated login attempts

```bash
Halt the agent's login flow immediately.
```

Expected: No more CAPTCHA triggers from repeated attempts.

### Step 2: Switch to API-based access

```bash
Use HubSpot API keys or OAuth tokens for what the agent needs.
```

Expected: The agent works without any browser login.

### Step 3: Or seed a session legitimately

```bash
If browser context is truly needed, authenticate once manually and reuse the session.
```

Expected: The agent operates in an already-logged-in context.

### Step 4: Reduce login frequency

```bash
Cache sessions and reuse them instead of logging in per run.
```

Expected: Fewer logins means fewer CAPTCHA triggers.

### Step 5: Verify the setup completes

```bash
Run the setup flow via the API path.
```

Expected: It finishes with no CAPTCHA involved.

## When this applies

- Agents hit CAPTCHAs on HubSpot logins
- Browser automation times out at login challenges
- You are automating HubSpot setup

## When it doesn't

- The credentials are wrong (fix those; do not hammer the login)
- The API covers the need (use it and skip the browser)
- You are tempted to bypass the CAPTCHA (do not; use the sanctioned path)

## Compatibility

HubSpot API and OAuth. Browser automation as a fallback only.

## Variant phrasings

### hubspot login captcha automation blocked

Same block. The sanctioned path is API access, not CAPTCHA solving.

### agent stuck hubspot captcha

Stuck at a CAPTCHA means the approach is wrong. Switch to API or seeded sessions.

### browser automation captcha timeout

Timeouts at CAPTCHAs are the protection working. Respect it and reroute.

## Why it happens

Repeated automated logins trigger HubSpot's abuse protection, which presents a CAPTCHA the agent cannot solve. The timeout follows because the agent waits on a challenge with no exit. The right move is to stop logging in through the browser at all.

## Edge cases

- Never build CAPTCHA bypasses; they violate terms and break constantly
- Session reuse needs secure storage; treat seeded sessions like credentials
- If the API truly cannot do it, do that step manually and automate around it

## If it still fails

- Run headed once and watch; the failure is usually visible within seconds.
- Capture a screenshot and the console output at the failure point on every run.
- Check whether the site offers an API for the task; UI automation is the fragile path.
- Test with a fresh browser profile to rule out cookie or cache state.
- If the site added bot protection, stop and use the sanctioned path. Do not work around it.

## Prevention

- Prefer APIs over browser automation wherever the site offers one.
- Screenshot on every failure so flakes are diagnosable.
- Use resilient selectors and re-validate them on a schedule.
- Keep automation accounts' sessions and auth factors maintained.
- Rate-limit automation traffic so it never looks like an attack.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_25BGV5G3uShlmLiFcFOe4A
