Web Testing using Selenium – fix for error “java.lang.NullPointerException: sessionId should not be null; has this session been started yet?”

07 / May / 2008 by Deepak 15 comments

I have a big fan of Selenium and have been using Selenium for quite some time for testing of web-applications.

Recently, I upgraded my machine to Ubuntu Hardy Heron and the next day, I found that all the selenium tests started failling on my machine. On digging through the logs, I found the following information in the Selenium Server logs:

java.lang.RuntimeException: File was a script file, not a real executable: /usr/bin/firefox-bin

Before actually spotting this line, I was mis-led by other log messages; but I will not talk about them in this post.

The reason for the failing tests was that Selenium Server thought that the default executable found in the path (/usr/bin/firefox) was a script file and not an executable application for the browser. I am not sure why Selenium Server checks whether the path to the browser should not be a script.

The cause of the problem is that because of  Ubuntu Hardy Heron upgrade, my firefox also got upgraded from 2.x to 3.x. The firefox browser executable in 2.x is a binary file; whereas for firefox 3.x, it is a script (.sh) file. As a result of this change, the check done by  Selenium Server was failing.

I resolved this problem by providing explicit path to the Firefox 2 executable file in the java code. (I also tried providing explicit path to the Firefox 3 executable but that is no help).

So, the code for the Java Selenium test-case looks like this :

selenium = new DefaultSelenium("localhost", 4444, "*firefox /usr/lib/firefox/firefox-2-bin", url);

This is not a solution, if you want to test your app with Firefox 3. I haven’t figured out the solution for making it work with Firefox 3; but for the time being, I am happy with testing my application with Firefox 2.

If somebody has a solution for making it work with Firefox 3, please post the solution as a comment to the blog.



comments (15)

  1. Geraldine

    Hi,Uploaded source code is correct, double check on your side. I have compared wengilic-applocatiob.xml is same as in screenshot.May be you server is missing ADF/BPM libraries, its why deployment fails…Andrejus

  2. vineet

    Hi, i m getting following error on running selenium java code “sessionId should not be null; has this session been started yet?”

  3. Paja

    Hello guys, I found out something interesting.

    Firstly start the selenium and than set all the parameters.


    If you try to execute the code in a reversed order, you get the above mentioned sessionId error


    Good luck.

  4. Anes P.A

    Hi Friends,
    I am working in Fedora 12,php selenium RC. After starting the Selenium RC
    server running the Test not work it Give Error like:

    PHPUnit 3.3.17 by Sebastian Bergmann.


    Time: 0 seconds

    There was 1 error:

    1) testTitle(WebTest)
    RuntimeException: Could not connect to the Selenium RC server.

    Tests: 1, Assertions: 0, Errors: 1.

    How it can Remedy, Waiting for a FAST reply
    reply me at : anes(dot)pa@gmail(dot)com.

    thankfully Anes P.A

  5. Gordopolis

    Hi, the Thread.Sleep(2000); line doesn’t resolve this for me?

    Can anyone clarify what versions of firefox conflict with selenium? I am using FireFox 3.6.10 and Selenium server 1.0.3.


  6. vas

    Here is the solution for this.

    Put at least 1 sec or 2 sec wait before start selenium.

    selenium = new DefaultSelenium(“localhost”, 4444, “firefox”, “http://www.google.co.uk/”);
    Thread.Sleep(2000); //This is for C#. Use specific language code for wait

    After using the wait time I never got this problem. This is the work around and there is no fix from Selenium for this issue.

    Hope this helps lot.

  7. Matthias

    Hi guys! Have you figured out a solution for the sessionId being null problem?

    java.lang.NullPointerException: sessionId should not be null; has this session been started yet?

    I’m getting this every timie from my EasyB tests but not from regular tests. And yes, I’m calling the selenium.start() thingy after constructing the DefaultSelenium object.

  8. Godwin

    Hi priya,

    Even i have encountered that same problem.I have just started with selenium.Can you please tel me how do u managed that error??


  9. Priya

    Hi Friend,
    While executing Selenium RC in Windows XP, system, i got the below exception. Please let me know how to resolve this problem?

    java.lang.NullPointerException: sessionId should not be null; has this session been started yet?


Leave a Reply

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