learning-it by example

Back to the video

Browser Agents: Fill a Web Form with Playwright

A browser script tied to one page's ids can break the day the page changes. On my two test pages, a loop that looks first did not.

Video #33 ยท AI agents and MCP

Steps in the video

  1. 0:00 When the page changes, a script can break
  2. 0:30 The idea
  3. 0:56 Setup
  4. 1:21 Two versions of one page
  5. 1:54 The fixed script
  6. 2:11 The loop
  7. 2:53 Act, then look again
  8. 3:43 What really happened
  9. 4:35 What this does not show
  10. 5:05 Mistakes to avoid
  11. 5:33 My take and next steps
  12. 5:59 Recap

Files

  • agent.py (76 lines)
  • compare.py (47 lines)
  • shopsite.py (57 lines)

Download the code (zip)

Tested with

Python 3.12.15 | playwright==1.64.1

What this does not show

Two versions of a made-up form that I wrote, served on this computer. The step that decides is plain code with rules that match my labels; no language model is used, so prompt injection, logins, captchas and real sites are not tested.

Sources

Learning IT by Example.