Skip to content

Instantly share code, notes, and snippets.

@freynaud
Created May 11, 2011 10:38
Show Gist options
  • Save freynaud/966263 to your computer and use it in GitHub Desktop.
Save freynaud/966263 to your computer and use it in GitHub Desktop.
Issue1558
package org.openqa.grid.e2e.misc;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.grid.e2e.utils.GridConfigurationMock;
import org.openqa.grid.internal.Registry;
import org.openqa.grid.selenium.SelfRegisteringRemote;
import org.openqa.grid.web.Hub;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.net.PortProber;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class Issue1558 {
private Hub hub = Hub.getNewInstanceForTest(PortProber.findFreePort(),
Registry.getNewInstanceForTestOnly());
private URL hubURL = hub.getUrl();
@BeforeClass(alwaysRun = true)
public void prepare() throws Exception {
hub.start();
System.out.println(hubURL);
hubURL = new URL("http://" + hub.getHost() + ":" + hub.getPort());
SelfRegisteringRemote remote = SelfRegisteringRemote.create(GridConfigurationMock.webdriverConfig(hub.getRegistrationURL()));
remote.addFirefoxSupport();
remote.setTimeout(5000, 1000);
remote.launchRemoteServer();
remote.registerToHub();
}
@Test
public void test() throws MalformedURLException, InterruptedException {
DesiredCapabilities ff = DesiredCapabilities.firefox();
for (int i = 0; i < 10; i++) {
Thread.sleep(10);
new RemoteWebDriver(new URL(hubURL + "/grid/driver"), ff);
}
}
@AfterClass(alwaysRun = true)
public void stop() throws Exception {
hub.stop();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment