Example usage for org.openqa.selenium.net UrlChecker waitUntilAvailable

List of usage examples for org.openqa.selenium.net UrlChecker waitUntilAvailable

Introduction

In this page you can find the example usage for org.openqa.selenium.net UrlChecker waitUntilAvailable.

Prototype

public void waitUntilAvailable(long timeout, TimeUnit unit, final URL... urls) throws TimeoutException 

Source Link

Usage

From source file:org.openqa.grid.e2e.misc.GridViaCommandLineTest.java

License:Apache License

@Test
public void testRegisterNodeToHub() throws Exception {
    String[] hubArgs = { "-role", "hub" };
    GridLauncherV3.main(hubArgs);/* w w w .ja  v  a2 s .co m*/
    UrlChecker urlChecker = new UrlChecker();
    urlChecker.waitUntilAvailable(10, TimeUnit.SECONDS, new URL("http://localhost:4444/grid/console"));

    String[] nodeArgs = { "-role", "node", "-hub", "http://localhost:4444", "-browser",
            "browserName=chrome,maxInstances=1" };
    GridLauncherV3.main(nodeArgs);
    urlChecker.waitUntilAvailable(100, TimeUnit.SECONDS, new URL("http://localhost:5555/wd/hub/status"));

    WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),
            DesiredCapabilities.chrome());

    try {
        driver.get("http://localhost:4444/grid/console");
        Assert.assertEquals("Should only have one chrome registered to the hub", 1,
                driver.findElements(By.cssSelector("img[src$='chrome.png']")).size());
    } finally {
        try {
            driver.quit();
        } catch (Exception e) {
        }
    }

}