selenium « Intelligrape Groovy & Grails Blogs

Posts Tagged ‘ selenium ’

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

Posted by admin on May 7th, 2008

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.

-Deepak

  • Share/Bookmark
Posted in Java tools