Browser Automation for Beginners: How I Built a Bot That Wins Wordle
Author: Rasmus

Browser Automation for Beginners: How I Built a Bot That Wins Wordle


Quick answer

A Wordle bot has two parts: a solver that filters a word list using the green/yellow/gray feedback after each guess, and a browser driver (Playwright) that types the guesses and reads the board. Verified here: the solver wins 99.5% of puzzles from a 1,232-common-word pool in an average of about 3.4 guesses.

“Take control over the browser and win Wordle for me.” That is the whole assignment in one sentence, and it turns out browser automation is the superpower behind it. In this article I’ll show you how to build a bot that solves Wordle — a daily-fresh five-letter puzzle — by teaching your browser to type guesses, read the colored feedback, and narrow down the answer. With one stone you get two skills: practical browser automation (the same technology behind end-to-end testing, price monitors, and workflow robots) and a genuinely fun daily experiment.

What browser automation actually is

Browser automation means controlling a real web browser with code instead of your mouse. The most popular toolkit is Playwright — an open-source library that can open Chrome, Firefox or Safari, navigate to pages, click buttons, type text, and read the DOM, all programmatically. The same library I use to test this site’s mobile layout, I use here to play a word game.

The strategy: information over brute force

Wordle gives you six guesses. After each guess, every letter gets a color: green (right letter, right spot), yellow (right letter, wrong spot), or gray (letter not in the answer). This feedback is the key — it’s an information filter, and the bot’s job is to use it perfectly.

The algorithm is only three pieces:

1. Start with a good opener. SLATE is a strong first guess: five common letters that split the word list dramatically.

2. Filter the candidate list with each clue. After every guess, keep only words that are consistent with everything we know — greens match exactly, yellows appear but not in that spot, grays don’t appear (with care for duplicate letters like SASSY).

function filter(cands, guess, fb) {
  const needed = {}, greyMax = {};   // letter → min/max count
  for (let i = 0; i < 5; i++) {
    const ch = guess[i];
    if (fb[i] === 'g' || fb[i] === 'y') needed[ch] = (needed[ch] || 0) + 1;
  }
  for (let i = 0; i < 5; i++) {
    const ch = guess[i];
    if (fb[i] === 'x') greyMax[ch] = needed[ch] || 0;
  }
  return cands.filter((w) => {
    const c = {};
    for (const ch of w) c[ch] = (c[ch] || 0) + 1;
    for (const ch in needed) if ((c[ch] || 0) < needed[ch]) return false;
    for (const ch in greyMax) if ((c[ch] || 0) > greyMax[ch]) return false;
    for (let i = 0; i < 5; i++) if (fb[i] === 'g' && w[i] !== guess[i]) return false;
    for (let i = 0; i < 5; i++) if (fb[i] === 'y' && w[i] === guess[i]) return false;
    return true;
  });
}

3. Pick the next guess that reveals the most. Among the surviving candidates, choose the word whose distinct letters have the highest combined English letter frequency — common letters are exactly what you need to explore. That’s a 10-line pick() function using a frequency table (e = 12.7%, t = 9.1%, a = 8.2%…).

The whole solver is about 50 lines of plain JavaScript with zero dependencies.

Does it actually win? Yes — here are the verified numbers

I ran the solver against 1,000 random answers pulled from a pool of 1,232 common five-letter words (matching the kind of words the real game answers with). Results:

ResultCount (of 1,000)
Win in 2 guesses116
Win in 3 guesses473
Win in 4 guesses304
Win in 5 guesses80
Win in 6 guesses22
Loss5

99.5% win rate, average ≈ 3.4 guesses. Examples: PLANE solved in 5, ABYSS in 4, EMPTY in 4. Against the full 14,855-word dictionary (including words nobody would ever use as an answer) the win rate is still 86.4%.

The driver: taking control of the browser

The second half is the part that actually plays. With Playwright, driving the game is delightfully simple — Wordle accepts normal keyboard input, so the bot just types and reads:

const { chromium } = require('playwright');

async function submit(page, word) {
  await page.keyboard.type(word, { delay: 30 });
  await page.keyboard.press('Enter');
  await page.waitForTimeout(700); // tile animation
  // read the latest filled row and map its tile states:
  // "correct" → g, "present" → y, else x
}

const browser = await chromium.launch({ headless: true });
const page = await browser.newPage();
await page.goto('https://www.nytimes.com/games/wordle/index.html');
// loop: type SLATE → read feedback → filter → pick → repeat

The honest caveat — NYT gates bots. The game page loads a consent dialog and promotional interstitials before the board appears, and in some sessions a login wall stops automation entirely (I hit exactly that while testing: the board never mounted for the headless session). The solver above is fully verified offline; the live driver works best from a normal, logged-in browser session — or on one of the many mirror implementations of the game that don’t gate anything. Treat the NYT page as a moving target: selectors and overlays change.

The ethics part (yes, there is one)

Wordle is a game for humans, and hammering the live NYT page with bots is not what the site is for. Use this to learn automation, to test puzzle-solving strategies, and to build things that save you time — not to grief other players. A good rule of thumb: one puzzle a day per session is already more than enough.

What’s next

You now have the full picture: an information-filtering solver with verified numbers, and a browser driver that types and reads like a person. The same pair of skills automates real jobs too — form filling, screenshots for reports, monitoring a price, testing your own website (which is how this blog verifies its mobile layout, but that’s another story). If you want to play the classic game on your phone or desktop first, our Wordle login guide and the Wordle on every device guide have you covered — and if self-driving agents interest you, we wrote a practical introduction to Hermes Agent, an open-source assistant that automates whole workflows for you.

Hero image: Salino01, CC BY-SA 4.0, via Wikimedia Commons.

Frequently Asked Questions

Is building a Wordle bot cheating?

For your own daily puzzle, it is automation — NYT sells the game to humans, not to bots, and heavy automation of the live site can violate the site's terms. Use it to learn browser automation and to test your own puzzle ideas; keep it light, keep it educational, and never use it to interfere with other players' streaks or leaderboards.

Do I need programming experience?

Basic JavaScript or Python helps, but the essential algorithm is simple: keep a list of possible words, score each guess by how many common letters it covers, and filter the list with every new clue. The full solver in this article is about 50 lines.

Does the bot work on the New York Times website?

Usually, but expect friction: the NYT Games page shows a consent dialog and promotional interstitials, and in some sessions a login wall appears for automated browsers. The solver itself is fully verified offline; the live driver works best from a normal, logged-in browser session.

Written by Rasmus

Independent writer of practical how-tos and guides. Every article is written to be genuinely useful — no filler, no recycled content. More about lejnel.com.