Stopping ASP WebDev and Selenium servers from command line

柔情痞子 提交于 2019-12-04 21:16:14

Here is what i do locally, but should work remotely too with a simple http get request:

http://localhost:4444/selenium-server/driver/?cmd=shutDown

or for post 1.0.1 versions of Selenium:

replace "shutDown" with "shutDownSeleniumServer"

James, I managed to solve Selenium starting/stopping problem by applying the test assembly initialization and cleanup mechanism (see the rest of the discussion on my blog):

[AssemblyFixture]
public class SeleniumTestingSetup : IDisposable
{
    [FixtureSetUp]
    public void Setup()
    {
        seleniumServerProcess = new Process();
        seleniumServerProcess.StartInfo.FileName = "java";
        seleniumServerProcess.StartInfo.Arguments =
            "-jar ../../../lib/Selenium/selenium-server/selenium-server.jar -port 6371";
        seleniumServerProcess.Start();
    }

    /// <summary>
    /// Performs application-defined tasks associated with freeing, releasing, or
    /// resetting unmanaged resources.
    /// </summary>
    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    /// <summary>
    /// Disposes the object.
    /// </summary>
    /// <param name="disposing">If <code>false</code>, cleans up native resources. 
    /// If <code>true</code> cleans up both managed and native resources</param>
    protected virtual void Dispose(bool disposing)
    {
        if (false == disposed)
        {
            if (disposing)
                DisposeOfSeleniumServer();

            disposed = true;
        }
    }

    private void DisposeOfSeleniumServer()
    {
        if (seleniumServerProcess != null)
        {
            try
            {
                seleniumServerProcess.Kill();
                bool result = seleniumServerProcess.WaitForExit(10000);
            }
            finally
            {
                seleniumServerProcess.Dispose();
                seleniumServerProcess = null;
            }
        }
    }

    private bool disposed;
    private Process seleniumServerProcess;
}

We usually leave the Selenium server running all the time on our build servers, it's more practical that way.

Failing that, there's always the trusty old pskill. It's a big hammer approach, but it works a treat to kill off webdevwebserver :-)

I know very very little about selenium, so apologies in advance if pskill is no good for stopping it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!