Null session Id in Firefox with C#

274 views
Skip to first unread message

RedRose123

unread,
Feb 4, 2010, 8:10:59 AM2/4/10
to Selenium Users
Please help. I would like to lean Selenium with C# but can not get
started. I have spend several days investigating the issues and have
been unsuccessful. I keep getting a Null session Id when I try to use
selenium C# with firefox. When I use IE, I get a dialog box saying
string is incorrect and it opens on the home page. I have
successfully used Firefox with Selenium Perl.

I have written a very basic script that logs on to google and does a
search.

I have tried the following combinations -

selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://
www.google.co.uk");
selenium = new DefaultSelenium("localhost", 4444, "*iehta", "http://
www.google.com/");
selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://
www.google.co.uk");
selenium = new DefaultSelenium("localhost", 4444, "*chrome C:/Program
Files/Mozilla Firefox/firefox.exe", "http://www.google.com/");
selenium = new DefaultSelenium("localhost", 4444, "*iexplore C:/
Program Files/Internet Explorer/iexplore.exe", "http://
www.google.co.uk/");

I have alse tried -

selenium.Open("http://www.google.com/");

I have set the PATH environment variable in MS Vista to firefox and
iexplorer directories. I have re-booted the laptop several times.

Here is the error from Firefox -

12:45:37.945 INFO - Launching Firefox...
12:45:52.832 INFO - Got result: OK,2926f777a94647ab8d6dde84bebfbab3 on
session 2926f777a94647ab8d6dd
e84bebfbab3
12:45:53.473 INFO - Command request: testComplete[, ] on session
2926f777a94647ab8d6dde84bebfbab3
12:45:53.482 INFO - Killing Firefox...
12:45:53.876 INFO - Got result: OK on session
2926f777a94647ab8d6dde84bebfbab3
12:46:03.944 INFO - Command request: open[http://www.google.com/, ] on
session null
12:46:03.954 ERROR - Exception running 'open 'command on session null
java.lang.NullPointerException: sessionId should not be null; has this
session been started yet?
at
org.openqa.selenium.server.FrameGroupCommandQueueSet.getQueueSet(FrameGroupCommandQueueSe
t.java:214)
at
org.openqa.selenium.server.commands.SeleniumCoreCommand.execute(SeleniumCoreCommand.java:
34)
at
org.openqa.selenium.server.SeleniumDriverResourceHandler.doCommand(SeleniumDriverResource
Handler.java:549)
at
org.openqa.selenium.server.SeleniumDriverResourceHandler.handleCommandRequest(SeleniumDri
verResourceHandler.java:364)
at
org.openqa.selenium.server.SeleniumDriverResourceHandler.handle(SeleniumDriverResourceHan
dler.java:125)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
at org.mortbay.http.HttpServer.service(HttpServer.java:909)
at org.mortbay.http.HttpConnection.service(HttpConnection.java:
820)
at
org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:986)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:
837)
at
org.mortbay.http.SocketListener.handleConnection(SocketListener.java:
245)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:
357)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:
534)
12:46:04.101 INFO - Got result: ERROR Server Exception: sessionId
should not be null; has this sessi
on been started yet? on session null

David Burns

unread,
Feb 4, 2010, 10:53:28 AM2/4/10
to Selenium Users
have you got selenium.Start(); in your code? The error you are showing
tends to appear when you try use the browser without having started
it.

David Burns
http://www.theautomatedtester.co.uk/

On Feb 4, 1:10 pm, RedRose123 <steven.kil...@rocketmail.com> wrote:
> Please help.  I would like to lean Selenium with C# but can not get
> started.  I have spend several days investigating the issues and have
> been unsuccessful.  I keep getting a Null session Id when I try to use
> selenium  C# with firefox. When I use IE, I get a dialog box saying
> string is incorrect and it opens on the home page.  I have
> successfully used Firefox with Selenium Perl.
>
> I have written a very basic script that logs on to google and does a
> search.
>
> I have tried the following combinations -
>

> selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://www.google.co.uk");
> selenium = new DefaultSelenium("localhost", 4444, "*iehta", "http://www.google.com/");
> selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://www.google.co.uk");


> selenium = new DefaultSelenium("localhost", 4444, "*chrome C:/Program
> Files/Mozilla Firefox/firefox.exe", "http://www.google.com/");
> selenium = new DefaultSelenium("localhost", 4444, "*iexplore C:/

> Program Files/Internet Explorer/iexplore.exe", "http://www.google.co.uk/");

RedRose123

unread,
Feb 4, 2010, 11:07:41 AM2/4/10
to Selenium Users
Hi David,

Yep, its in there. I also added a sleep thread but still can not get
it to work.

System.Threading.Thread.Sleep(10000);
selenium.Start();

The code was copied exactly from Selenium IDE except for two changes.

1) I tried various browsers and paths.
selenium = new DefaultSelenium(. ... "

2) I added this class to execute the code at the end of SeleniumTests
namespace.
------------------------------------------------------------------------------------------------------------
public class seleniumTest
{
// contains Main(), indicates that the program starts
public static void Main()
{
Untitled s = new Untitled();
s.SetupTest();
s.TeardownTest();
s.TheUntitledTest();
}
}
--------------------------------------------------------------------------------------------------------------

On Feb 4, 3:53 pm, David Burns <theautomatedtes...@googlemail.com>
wrote:


> have you got selenium.Start(); in your code? The error you are showing
> tends to appear when you try use the browser without having started
> it.
>

> David Burnshttp://www.theautomatedtester.co.uk/

David Burns

unread,
Feb 4, 2010, 1:31:40 PM2/4/10
to Selenium Users
The way that you have got your tests is not in a standard format. Its
best practise to run your tests with something like NUnit or MS Test.
I have a tutorial on my site at http://www.theautomatedtester.co.uk/seleniumtraining/selenium_csharp_nunit.htm
that will walk you through the process of creating tests in C# and
running them with NUnit.

David Burns
http://www.theautomatedtester.co.uk/

Steven Killen

unread,
Feb 5, 2010, 5:48:48 AM2/5/10
to seleniu...@googlegroups.com

Thanks David,  that information is really helpful.

--- On Thu, 4/2/10, David Burns <theautoma...@googlemail.com> wrote:
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsub...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


Steven Killen

unread,
Feb 12, 2010, 7:46:45 AM2/12/10
to seleniu...@googlegroups.com
Hi David,

I have just successfully run your tutorial and are no longer getting a Null session Id error.  Thanks, the tutorial was very helpful.

Regards,


Steve.


--- On Thu, 4/2/10, David Burns <theautoma...@googlemail.com> wrote:

From: David Burns <theautoma...@googlemail.com>
Subject: [selenium-users] Re: Null session Id in Firefox with C#
To: "Selenium Users" <seleniu...@googlegroups.com>
Date: Thursday, 4 February, 2010, 18:31

Reply all
Reply to author
Forward
0 new messages