Skip to content

Instantly share code, notes, and snippets.

@freynaud
Created June 13, 2011 09:19
Show Gist options
  • Save freynaud/1022511 to your computer and use it in GitHub Desktop.
Save freynaud/1022511 to your computer and use it in GitHub Desktop.
package com.ebay.spine.selenium;
import java.net.MalformedURLException;
import java.net.URL;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.webapp.WebAppContext;
import org.openqa.grid.selenium.SelfRegisteringRemote;
import org.openqa.grid.selenium.utils.SeleniumProtocol;
import org.openqa.grid.web.Hub;
import org.openqa.selenium.remote.server.DriverServlet;
import org.testng.ISuite;
import org.testng.ISuiteListener;
import com.ebay.spine.testsession.TestSession;
public class LocalWebDriverCapabilities implements ISuiteListener{
private static Server server = new Server();
@Override
public void onFinish(ISuite suite) {
try {
Hub.getInstance().stop();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onStart(ISuite suite) {
try {
// starts a local grid.
Hub.getInstance().start();
TestSession.setHubUrl(new URL(Hub.getInstance().getUrl()+"/grid/driver"));
SelfRegisteringRemote remote = SelfRegisteringRemote.create(SeleniumProtocol.WebDriver, 5555, Hub.getInstance().getRegistrationURL());
// register a node.
remote.addFirefoxSupport(null);
remote.addInternetExplorerSupport();
remote.addChromeSupport();
// not more than 1 browser to ease debugging.
remote.setMaxConcurrentSession(1);
remote.setTimeout(30000, 10000);
remote.launchRemoteServer();
remote.registerToHub();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment