Skip to content

Instantly share code, notes, and snippets.

@krmahadevan
Created January 27, 2012 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save krmahadevan/1688716 to your computer and use it in GitHub Desktop.
Save krmahadevan/1688716 to your computer and use it in GitHub Desktop.
A Simple listener which takes care of starting and stopping the Selenium Server
package com.test.listeners;
import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;
import org.testng.ISuite;
import org.testng.ISuiteListener;
import org.testng.Reporter;
public class SeleniumStarterListener implements ISuiteListener {
private static SeleniumServer server = null;
private static RemoteControlConfiguration configuration = null;
private static boolean isServerStarted = false;
public void onStart(ISuite suite) {
configuration = new RemoteControlConfiguration();
configuration.setPort(4444);
try {
server = new SeleniumServer(configuration);
server.boot();
isServerStarted = true;
Reporter.log("Started the selenium server", true);
} catch (Exception e) {
e.printStackTrace();
}
}
public void onFinish(ISuite suite) {
if (isServerStarted) {
server.stop();
Reporter.log("Stopped the selenium server", true);
}
}
}
@Sudharshan-r
Copy link

Where is RemoteControlConfiguration and SeleniumServer class.please let me know

@tarun3kumar
Copy link

I guess they all refer to old selenium RC API which required selenium server to be started before running the test.
Notice that Selenium RC has been deprecated and you should be using WebDriver instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment