Conveniently the software engineering community has a solution to this class of problems and it's called system testing. In this context, System testing means interact with the web pages via a browser just like users do. I did some digging and I couldn't find a perfect (or awesome) tool for system testing web apps.
I was able to get a tool that could drive FireFox and Chrome (IE isn't working). This tool had some warts, and took some experimentation to get working, but it mostly meets the needs. Please comment if you find a better tool!
The tool I used is called Selenium, and it's scriptable via python (also Java and C#). Selenium is able to impersonate a user performing actions via the common web browsers. The code below should make reasonable sense to someone familiar with the DOM. As usual, the code is also available on bitbucket:
 InnerText isn't support in FF, need to use InnerHtml instead.