Created
January 27, 2012 13:15
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} |
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
Where is RemoteControlConfiguration and SeleniumServer class.please let me know