AI and automation
Why does automation fail on login pages?
Because the login form is the most attacked page on most sites, so it carries the most defenses at once. A script usually trips one of them: a CAPTCHA, a hidden token, a request built by JavaScript, a device check, a rate limit or a second factor.
The short answer
Credential stuffing and account takeover target login endpoints, so sites protect them more than any other page. A script that logs in to an account it is entitled to use (your own accounts, a test account, a client portal your company has access to) meets the same defenses as an attacker. Failures fall into a handful of groups, and each leaves recognizable traces. Identify the group first, then fix that specific step.
The usual culprits
Hidden form fields and CSRF tokens
Login forms often include a hidden csrf_token, authenticity_token or nonce that must be sent back with the credentials, and that only matches the session cookie set when the form was loaded. Posting credentials alone, or with a token from another session, returns an error or reloads the form. Load the form, read every hidden input, keep the cookies, and post them together.
Requests built by JavaScript
Modern sign-in pages rarely submit a plain form. Scripts hash or encrypt fields, add timestamps or device data, and send JSON to an API. Replaying the visible form fails. Either drive a real browser, or study the request in DevTools and reproduce it exactly, including headers.
CAPTCHAs and invisible scoring
A reCAPTCHA, Turnstile or GeeTest widget may sit on the form, or reCAPTCHA v3 may score the attempt silently. Missing or bad tokens cause "please try again" messages that do not mention a CAPTCHA at all. Look for widget scripts in the page and token fields in the outgoing request. Solving is the standard step here: read the site key and action, send a task to GateSolver, and include the token in the login request.
Device and browser checks
Bot management products fingerprint the browser on the login page. Headless signals, a webdriver flag or a TLS fingerprint that does not match the user agent can lead to a silent rejection, even with correct credentials and a valid token.
Rate limits and lockouts
Repeated attempts, especially failures, trigger per-IP and per-account limits. A test script that retries a broken login in a loop can lock the account. Stop after one or two failures and investigate.
Second factors and new-device prompts
One-time codes, email confirmations and "is this you?" prompts appear for new devices or locations. For automation of your own accounts, use the site's supported options: app passwords, API tokens, or a test environment with MFA configured for automation.
A diagnostic sequence
- Log in by hand in a normal browser with DevTools open, and save the login request as a HAR or copy it as cURL.
- Run your script and capture its login request the same way.
- Compare them field by field: URL, method, headers, cookies, body keys, token values.
- Read the response body of the failure. Sites often say more there than on screen.
Nearly every login failure shows up as a difference in that comparison.
Keep the session once you have it
Logging in on every run multiplies exposure to all these defenses. After a successful login, save the session cookies or browser state and reuse them until they expire; the page on managing cookies and sessions shows how. Many teams log in once a day or less and run everything else on the saved session.
Where agents struggle most
AI agents fail on logins for the same reasons, plus their own: they type credentials into the wrong field, misread error messages, or stall at widgets. Give them a login tool written in code rather than asking them to improvise, and a CAPTCHA tool for the widget step. The article on agents and login CAPTCHAs walks through such a setup. The broader how-to for scraping behind logins is on handling login pages.
Stay on the right side
Only automate logins to accounts you own or are authorized to use, and respect the site's terms. GateSolver does not permit credential stuffing, account takeover or fake account creation; its use on login pages is for your own access, testing and accessibility.
Common questions
Why does my script get "invalid credentials" with the right password?
Often a missing hidden token, a failed CAPTCHA check or a device check is reported with a generic message.
Do I need a browser to automate a login?
Not always. Plain HTTP works if you reproduce the exact request, including tokens; script-built requests are easier in a browser.
How do I find the CAPTCHA on a login page?
Look for reCAPTCHA, Turnstile or GeeTest scripts in the page, and token fields in the request the form sends.
How can I avoid account lockouts while testing?
Stop after one or two failures, investigate, and reuse saved sessions instead of logging in repeatedly.
Can I automate logins to other people's accounts?
Only with their authorization. Credential stuffing and account takeover are prohibited and unlawful.
Keep reading
- How should scrapers handle login pages?Log in once with your own account, keep the session cookies, refresh them only when they expire, and pace requests.
- CrewAI agents and login CAPTCHAsA CrewAI tool that clears the CAPTCHA on a login form you may automate and hands the session back to the crew.
- Account takeover (ATO)Credential stuffing and other ways attackers seize accounts, why login forms carry CAPTCHAs, and why solvers must not be used for it.
- How do I manage cookies and sessions in automation?Treat each session as a bundle of cookies, storage, IP and browser identity, saved and retired as one unit.