So, I have some code set up via Gallio, to start the selenium server before each test session, and shut it down when the session finishes (all tests have run). It starts the server fine, but I can't seem to get it to stop the server. I'm pretty sure I've done something wrong, but I can't see what. Can you help me?
I'm using:
* Selenium Server 2.0b4
* Selenium WebDriver 2.0b4
* Visual Studio 2010 (C#)
* ReSharper
* Gallio
Here is my code:
[AssemblyFixture]
public class SeleniumSetup : IDisposable
{
private Process seleniumServer;
private Boolean disposed;
[FixtureSetUp]
public void Setup()
{
const string javaFileLocation = @"C:\opt\java\bin\java.exe";
const string jarFileLocation = @"C:\my\autotests\Selenium\selenium-server.jar";
var seleniumServer = new Process
{
StartInfo =
{
FileName = javaFileLocation,
Arguments = "-jar " + jarFileLocation + " -port 4444 -timeout 90 -browserSideLog -ensureCleanSession -trustAllSSLCertificates -log selenium-server.log",
WorkingDirectory =
jarFileLocation.Substring(0, jarFileLocation.LastIndexOf("\\")),
UseShellExecute = true
//WindowStyle = ProcessWindowStyle.Hidden
}
};
seleniumServer.Start();
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (false == disposed)
{
if (disposing)
DisposeOfSeleniumServer();
disposed = true;
}
}
[FixtureTearDown]
private void DisposeOfSeleniumServer()
{
if (seleniumServer != null)
{
try
{
seleniumServer.Kill();
seleniumServer.WaitForExit(10000);
}
finally
{
seleniumServer.Dispose();
seleniumServer = null;
}
}
}
}