More on web testing

I’m fairly convinced that it should be possible to set up something that “records” you testing a web page. In a world without security restrictions, it’d work. Basically, you have a bookmarklet which creates a sidebar, and then the sidebar watches what you do in the main frame and stores a script.
In a bit more detail:
The bookmarklet would be called something like “Record a macro on this page“. When you click it, it creates a link in the body of the page, which looks something like this:
<a href="http://webtest.kryogenix.org/" onclick="if (window.sidebar.addPanel) { window.sidebar.addPanel(this.href);" rel="sidebar" target="_search">test</a>
(The very useful sidebars in firebird, mozilla, opera and IE details at unescaped beta helped immeasurably here.) The rel="sidebar" creates a sidebar in Opera. The target="_search" creates a sidebar in IE. The JavaScript addPanel stuff creates a sidebar in Mozilla and Mozilla Firebird. Then the code clicks on the link. Pow, sidebar.
The sidebar then, when it loads, attaches a shedload of handlers to the code in the main page—an onclick to everything, onchange to form elements, all that sort of thing. So when you do anything on the page, it gets told about it. When it gets told about something, it stores that away in a script. You should then be able to save that script and replay it, and the automated system will mimic all your clicks and form typing.

Why this won’t work

Well, there are three reasons. The first is that the sidebar won’t be able to read the contents of your page, because it comes from a different domain, and the security model (which exists for good reasons) won’t let it. I think you could get around this by having the bookmarklet construct your whole sidebar page with document.write statements, but firstly this would make it a very, very complex bookmarklet indeed, and secondly there are limitations on the size of a bookmarklet, especially in IE.
The second reason is that the sidebar won’t be able to access the local filesystem to save the script, again because of the security model. You might be able to fix this with signed scripts, but then I suspect what you will get is ugly confusing security dialogs. It’s possible that pages loaded from the local filesystem can save back to it, but that doesn’t appear to always be the case—Mozilla will, I think, need chrome URLs, and that then means that the test environment has to be installed and then it’s not an easy-to-use cross-browser thing, it’s a Moz XUL application.
The third reason is that when you submit a form, or follow a link, you stop tracking what’s happening in the page. That’s silly in a test environment; you need some way of saying “this thing here on page 2, that has to be there” so that you have some conditions for knowing whether your test has passed. I can’t think of a way around this, either—there’s no way that the security model will ever let you put a page in the sidebar that can watch what’s in the main content window, since that sidebar page could then tell someone nasty on the internet what you were browsing all the time. I’ve seen proxy applications, where the proxy seamlessly inserts stuff into your page—the ones designed for web testing, though, don’t do any JavaScript stuff, so they can only test form submissions and so on. I don’t want that—I want to be able to track what a user does the whole time they’re testing, including whether any interactive stuff on the page works.
Perhaps someone has already solved this. Is there anything that is cross-browser (it’s allowed to demand a modern browser, but at a flat minimum it must work in IE and Mozilla on Windows and Linux) and lets me do this sort of testing?

8 Responses to “More on web testing”

  1. There’s a piece of software out there called “Badboy”:http://www.badboy.com.au/ which looks like it’d do what you want, but unfortunately it only works for IE/Win. It can export to JMeter, but JMeter doesn’t really do all of what you want either.

    Nevertheless, it’s a place to start. I’ve always wished something like this existed for Mozilla. Anyone know of anything like this in development?

    Millennium
  2. You’re setting the bar high!

    So I have a project for Mozilla that: installs as a priveledged sidebar, saves data to the filesystem, and watchs page loads in the main window.

    It’s Mozilla only — circumventing the chrome restriction.  There’s not going to be a way to bypass those restrictions thats common for moz and ie.

    It knows how to save data to the filesystem, but doesn’t record or playback events — nonetheless, it’s a good start for this type of tool.

    Andyed
  3. This is more doable with a proxy.

    Put a web proxy betwen your browser and any server and you now can record any part of your web transaction.

    There are a few Web testing tools that take this approach listed on freshmeat.net

    Clayton Scott
  4. Web proxies will only record settings that get sent back to the server. So, as I said above, “I’ve seen proxy applications, where the proxy seamlessly inserts stuff into your page—the ones designed for web testing, though, don’t do any JavaScript stuff, so they can only test form submissions and so on. I don’t want that—I want to be able to track what a user does the whole time they’re testing, including whether any interactive stuff on the page works.”

    sil
  5. I’m looking for the same thing. I’d be willing to settle for Mozilla or IE only. After seeing projects that tortuously try to reconstruct the page in order to script it, I thought why duplicate javascript, dom, and cookies, come up with your own script and event model? You’re bound to introduce bugs. HttpUnit + JTidy + Rhino + SunJSSE + custom cookie, session handling DOES NOT behave the same as IE6.0 or Mozilla 1.7.3. I’m wondering if your idea of a sidebar (or frameset) with a build of Mozilla with security yanked out would be enough to do it? I’ve tested it on local objects, and it works pretty good there. Combined with a DOM inspector to provide input, you could easily have a “test controller” frame drive a “test subject” frame with nothing more than the built in javascript DOM.

    Aaron
  6. Hi all.

    I’ve investigated this rather thoroughly too, I think my initial need is the same as Sils : record the user interactions within a browsing session (not just the URL calls), for plugging the recorded script back into a real browser. By real browser I mean one which will play the whole show (with UI redirect to /dev/null): fetch all content, then execute of javascripts, possibly even initiate flash animations &c.. The player would of course record all stats for whatever use you might want them (performance testing, content check, bug track).

    There are many problems, Sil enumerates a good few, security being the major one of course.

    I’ve investigated several possibilities: – do an ‘anonymizer.com’ style frontal, which redirects all URLs contained within a page. Frankly anonymizer.com has trouble with content using this method, and javascript &c. are impossible to do. – place a recording UI on top of Mozilla. See Sils post for this. – set up a reverse proxy-proxy pair with a recorder and cookie sessions added in the middle. Javascript and other nifty stuff won’t be possible.

    The most promising is surely slapping a frontal on a Mozilla engine, But it will be trickier than just a XUL extension. Handling widgets for one will be rather fun.

    Unfortunately, I don’t have the competence to code this, but if we’re a few interested, it might be worth the while to set up a Mozdev project?

    Michael Tonkin
  7. Hi there,

    please find a good and ,low cost testing tool JStudio SiteWalker to automate web application GUI and validate any content. Because of it’s element based action handling many scenarios can be automated, many expensive tools cannot do. Find more info at http://www.jstudio.de

    Have fun.

    Frank
  8. Hai All,
    I have somewhat similar problem.
    I am testing a site using HttpUnit .
    The site uses Javascript Redirects instead of normal Hyperlinks.

    I must now test the links & navigate to the next page.
    I can use ieHttpHeader1 v1.6 or the proxy http://freshmeat.net/projects/loxy/
    to show the headers sent between the browser and server.
    But is it possible to simulate the same in HttpUnit and continue Testing.

    kiran

Leave a Reply

OpenID is a decentralised authentication system. If you use LiveJournal or Vox you already have an OpenID; just use the URL of your homepage there. See also how to get yourself an OpenID.