Prompt
How do I automate form fills and submissions in Chrome without using Selenium?
Latest observation
You can automate Chrome form fills and submissions without Selenium in a few different ways, depending on whether you want to control an existing browser, run repeatable test flows, or just do simple automation.
Best options
1) Chrome DevTools Protocol (CDP)
This is the most direct “no Selenium” approach for automating Chrome. You can:
- open pages
- click elements
- type into inputs
- submit forms
- read page content
Common libraries:
- Node.js:
puppeteerorplaywright(both can control Chrome; not Selenium) - Raw CDP: connect directly to Chrome’s debugging port
Example with Puppeteer
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
await page.goto('https://example.com/form');
await page.type('#name', 'Alice');
await page.type('#email', 'alice@example.com');
await page.click('#submit');
// wait for navigation if needed
await page.waitForNavigation();
await browser.close();
})();
2) Playwright
Playwright is very good for browser automation and often simpler than Selenium. It supports Chrome, Chromium, and other browsers.
Example with Playwright
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch({ headless: false });
const page = await browser.newPage();
await page.goto('https://example.com/form');
await page.fill('#name', 'Alice');
await page.fill('#email', 'alice@example.com');
await page.click('#submit');
await browser.close();
})();
3) Chrome Extensions
If you want automation that runs inside Chrome itself, you can build a Chrome extension that:
- injects content scripts
- fills form fields
- clicks submit buttons
This is useful when you want automation tied to a specific site or user workflow.
4) Native automation tools
If your goal is desktop-level automation rather than browser scripting:
- AutoHotkey (Windows)
- AppleScript / Shortcuts (macOS)
- xdotool or wmctrl (Linux)
These simulate keyboard/mouse input, so they’re less robust than DOM-based automation but can work for simple tasks.
5) Programmatic HTTP requests
If the form submission is just a normal POST request and doesn’t require heavy JavaScript interaction, you may be able to:
- inspect the network request
- reproduce it using
fetch,axios, orrequests
This is often the most reliable and lightweight method when the site allows it.
Example in Python:
import requests
data = {
"name": "Alice",
"email": "alice@example.com"
}
r = requests.post("https://example.com/submit", data=data)
print(r.status_code)
Which one should you use?
- For full browser automation: Playwright
- For direct Chrome control: CDP / Puppeteer
- For in-browser repetitive workflows: Chrome extension
- For simple submissions: HTTP requests
- For UI-only automation: AutoHotkey / AppleScript
Important notes
- Some sites use CSRF tokens, dynamic fields, or bot detection, so plain HTTP requests may not be enough.
- If the form is inside an iframe or shadow DOM, the automation code needs to handle that specifically.
- Avoid automating sites in ways that violate their terms of service.
If you want, I can give you a ready-to-run example in Node.js, Python, or a Chrome extension.