Adding XML support to Selenium Remote Control

If you are one of the chosen few using (or having to use) the Selenium suite of software test tools, then you may have discovered that it does not natively support XML content. Here is a useful way to modify it so that it does:

  1. Download the latest version in JAR format from your usual Maven repository (e.g. selenium-server-0.9.0.jar)
  2. Unpack this JAR somewhere on your system
  3. $ cd /tmp
    $ mkdir ss090 ; cd ss090
    $ jar xf ~/Desktop/selenium-server-0.9.0.jar

  4. Edit the file /tmp/ss090/core/scripts/selenium-browserbot.js and locate the getBody function (line 1573 approximately)
  5. Modify this function as follows:
  6. PageBot.prototype.bodyText = function() {
    if (this.getDocument() instanceof XMLDocument) {
    return new XMLSerializer().serializeToString(this.getDocument());
    } else {
    return getText(this.getDocument().body);

  7. Repack the JAR taking care to specify the correct MANIFEST file:
  8. $ cd /tmp/ss090
    $ jar cfm selenium-server-xml-0.9.0.jar META-INF/MANIFEST.MF *

  9. If you want to produce an MD5 signature for this JAR file, you can do so using the md5sum program.

Happy Trails …

3 thoughts on “Adding XML support to Selenium Remote Control”

  1. This is a very old blog post and yet this patch is still required. Do the openQA guys know about this issue?

  2. I have added selenium-server-standalone-2.2.0.jar. I didn’t get anything like getBody.
    But there was only one method with .bodyText. So i made changes in that. Hence it was working fine with firefox but not with internet explorer.
    Please tell me wat to do for internet explorer.

Leave a Reply