{"id":15,"date":"2008-05-07T18:02:57","date_gmt":"2008-05-07T12:32:57","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=15"},"modified":"2015-07-10T13:14:32","modified_gmt":"2015-07-10T07:44:32","slug":"web-testing-using-selenium-fix-for-error-javalangnullpointerexception-sessionid-should-not-be-null-has-this-session-been-started-yet","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/web-testing-using-selenium-fix-for-error-javalangnullpointerexception-sessionid-should-not-be-null-has-this-session-been-started-yet\/","title":{"rendered":"Web Testing using Selenium &#8211; fix for error &#8220;java.lang.NullPointerException: sessionId should not be null; has this session been started yet?&#8221;"},"content":{"rendered":"<p>I have a big fan of Selenium and have been using Selenium for quite some time for testing of web-applications.<\/p>\n<p>Recently, I upgraded my machine to <a title=\"Ubuntu Hardy Heron\" href=\"https:\/\/wiki.ubuntu.com\/HardyHeron\">Ubuntu Hardy Heron<\/a> 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:<\/p>\n<p><code>java.lang.RuntimeException: File was a script file, not a real executable: \/usr\/bin\/firefox-bin<\/code><\/p>\n<p>Before actually spotting this line, I was mis-led by other log messages; but I will not talk about them in this post.<\/p>\n<p>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.<\/p>\n<p>The cause of the problem is that because of\u00a0 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\u00a0 Selenium Server was failing.<\/p>\n<p>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).<\/p>\n<p>So, the code for the Java Selenium test-case looks like this :<\/p>\n<p><code>selenium = new DefaultSelenium(\"localhost\", 4444, \"*firefox \/usr\/lib\/firefox\/firefox-2-bin\", url);<\/code><\/p>\n<p>This is not a solution, if you want to test your app with Firefox 3. I haven&#8217;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.<\/p>\n<p>If somebody has a solution for making it work with Firefox 3, please post the solution as a comment to the blog.<\/p>\n<p>-Deepak<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":2},"categories":[1],"tags":[26,25,8],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/15"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=15"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/15\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=15"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=15"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=15"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}