• Jobs
  • About
  • Selenium Server 1.x support for Firefox 4 February 20, 2011

    Firefox 4 is currently in beta but I am getting ready to start using it for running my tests against, as I am sure most of you are too. Selenium server 1.x does not support Firefox 4 though. Here are steps you will have to follow to make it work:

    Testing Selenium server support for Firefox

    The quickest way to test if your selenium server is supporting the Firefox version installed on your machine is to start selenium server in an interactive mode. Let us walk through these steps.

    1. Run Selenium server in interactive mode. To do this run the command:
      java -jar selenium-server.jar -interactive -singleWindow
    2. Start new selenium browser session using the command:
      cmd=getNewBrowserSession&1=*firefox&2=http://www.google.com
    3. If you see a line saying Preparing Firefox profile... and no progress beyond that, there is a high likelihood that the Firefox browser version you have is not supported by your version of selenium server jar you have. If you have Firefox 4 and selenium 1.0.3, the next section shows how to fix the problem.
    4. If you don’t see a problem, run the following command:
      cmd=open&1=http://www.google.com

    If the browser starts and you see Google’s home page in it, your basic setup seems to be fine.

    Patching Selenium server to support Firefox 4

    These steps should work for you on Unix, Mac or cygwin on windows. In case you are not using any of these, you would need to figure out the corresponding steps for our platform.

    1. Create a directory where you could manipulate the jar’s contents.
      mkdir ~/selenium103
    2. Copy your selenium-server.jar file in the newly created directory and cd into it.
      cp selenium-server.jar ~/selenium103/.
      cd ~/selenium103
    3. Unzip the jar files contents here and delete the jar file.
      unzip selenium-server.jar
      rm selenium-server.jar
    4. First find all the *.rdf files – you should see 5 of them:
      find . -name "*.rdf"
      ./customProfileDirCUSTFF/extensions/{538F0036-F358-4f84-A764-89FB437166B4}/install.rdf
      ./customProfileDirCUSTFF/extensions/readystate@openqa.org/install.rdf
      ./customProfileDirCUSTFFCHROME/extensions/{503A0CD4-EDC8-489b-853B-19E0BAA8F0A4}/install.rdf
      ./customProfileDirCUSTFFCHROME/extensions/{538F0036-F358-4f84-A764-89FB437166B4}/install.rdf
      ./customProfileDirCUSTFFCHROME/extensions/readystate@openqa.org/install.rdf
      
    5. In each of these files you will see
      <em:maxVersion>3.6.*</em:maxVersion>

      Change them to

      <em:maxVersion>4.*</em:maxVersion>
    6. all the files are now patched. To jar them back up run the following steps:
      zip -r selenium-server *
      mv selenium-server.zip selenium-server.jar
      jar -cvfm selenium-server.jar META-INF/MANIFEST.MF *

    Rerun the browser tests as described earlier. Selenium should now be able to instantiate a new browser and drive it.

    Changes to your code to support Firefox 4

    In Firefox 4, when you run javascript functions using selenium RC like

    selenium.getEval("this.browserbot.getCurrentWindow().someFunction()")

    it will fail. This is because in Firefox 4 it wraps the objects. To unwrap it, you will have to do something like

    selenium.getEval("XPCNativeWrapper.unwrap(this.browserbot.getCurrentWindow()).someFunction()");

    Ofcourse, you have to ensure it doesn’t unwrap the object in FF versions < 4. There are a couple options for that too

    1. Either inspect the type of object returned by this.browserbot.getCurrentWindow() or
    2. Get the browser version. Again for this you can do this using javascript using a browser object navigator or useĀ  Selenium’s object by calling browser.getEval("browserVersion.firefoxVersion").

    Open issues with FF4

    Even after patching selenium and handling the browser object wrapping, there is still one issue I haven’t solved yet. Alerts and pop-ups generated through JavaScript are not handled in FF4 using selenium 1.x code. If anyone finds the solution, please share it with us here.

    Posted by Rahul Poonekar in : Selenium

    5 responses to “Selenium Server 1.x support for Firefox 4”

    1. Bob says:

      I followed your steps and I get beyond the preparing profile. It prepares and launches a window but selenium is not embedding itself into the browser

    2. Bob says:

      I get this error: Could not read chrome manifest file ‘C:\Program Files (x86)\Mozilla Firefox 4.0 Beta 12\extensions\{972ce4c6-7e08-4474-a285-3208198ce6fd}\chrome.manifest’.

    3. Rahul Poonekar says:

      When I searched the web for “Could not read chrome manifest file” I noticed that several people were encountering this issue with different Firefox 4 beta versions. I could not find a definitive solution to this problem. It also seems like people who had Firefox 3.x installed along with Firefox 4 beta, they didn’t seem to run into this problem. You could try uninstalling Firefox 4, install firefox 3.6 and then install firefox 4 beta in a different directory, and see if that helps.

      Btw, if you do have multiple versions of Firefox installed on your machine, you can tell Selenium which version to use by passing -DfirefoxDefaultPath to the selenium startup command. So in the case of starting selenium interactively, the command would be something like:
      java -jar selenium-server.jar -interactive -singleWindow -DfirefoxDefaultPath="C:\Program Files\Mozilla Firefox 4.0\firefox.exe"

      Please let us know if you find a solution to your error.

    4. Lenina says:

      This solution worked fine with me. Thanks a lot for publishing this online.

    5. Mike Ramsey says:

      We are moving off of FF3.6 but because we have selenium user-extensions we cannot (easily) move to Selenium 2. Needless to say, we are hitting the problems discussed in this thread.

      The selenium developers have packaged selenium 1 along with selenium 2 in the selenium 2 jar. The good news is that this selenium 1 is being maintained. Most of our problems went away by simply installing the selenium 2 jar. However, not all selenium 2 jars did the trick. Download
      selenium-server-2.xx.0.zip
      where xx may increment daily (yikes! but mostly selenium 2 changes) from:
      http://code.google.com/p/selenium/downloads/list

    Leave a Reply

    Your email address will not be published. Required fields are marked *