List of usage examples for org.openqa.selenium.net UrlChecker UrlChecker
UrlChecker
From source file:com.mengge.service.local.AppiumDriverLocalService.java
License:Apache License
private void ping(long time, TimeUnit timeUnit) throws UrlChecker.TimeoutException { URL url = getUrl();//from w ww . ja v a2s . c om try { URL status = new URL(url.toString() + "/status"); new UrlChecker().waitUntilAvailable(time, timeUnit, status); } catch (MalformedURLException e) { throw new RuntimeException("URL " + url.toString().toString() + "/status"); } }
From source file:com.thoughtworks.selenium.testing.SeleniumTestEnvironment.java
License:Apache License
public SeleniumTestEnvironment(int port, String... extraArgs) { try {/*from w ww. j a v a 2 s .co m*/ Path serverJar = new BuckBuild().of("//java/server/test/org/openqa/selenium:server-with-tests").go(); ArrayList<Object> args = Lists.newArrayList(); if (Boolean.getBoolean("webdriver.debug")) { args.add("-Xdebug"); args.add("-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"); } args.add("-jar"); args.add(serverJar.toAbsolutePath().toString()); args.add("-port"); args.add(String.valueOf(port)); if (Boolean.getBoolean("singlewindow")) { args.add("singlewindow"); } if (Boolean.getBoolean("webdriver.debug")) { args.add("-browserSideLog"); } args.addAll(Arrays.asList(extraArgs)); command = new CommandLine("java", args.toArray(new String[args.size()])); command.copyOutputTo(System.out); command.executeAsync(); PortProber.pollPort(port); seleniumServerUrl = "http://localhost:" + port; URL status = new URL(seleniumServerUrl + "/tests"); new UrlChecker().waitUntilAvailable(60, TimeUnit.SECONDS, status); } catch (Exception e) { throw new RuntimeException(e); } // appServer = new SeleniumAppServer(); // appServer.start(); appServer = new AppServer() { @Override public String getHostName() { return "localhost"; } @Override public String getAlternateHostName() { throw new UnsupportedOperationException("getAlternateHostName"); } @Override public String whereIs(String relativeUrl) { try { return new URL(seleniumServerUrl + "/" + relativeUrl).toString(); } catch (MalformedURLException e) { throw new RuntimeException(e); } } @Override public String whereElseIs(String relativeUrl) { throw new UnsupportedOperationException("whereElseIs"); } @Override public String whereIsSecure(String relativeUrl) { throw new UnsupportedOperationException("whereIsSecure"); } @Override public String whereIsWithCredentials(String relativeUrl, String user, String password) { throw new UnsupportedOperationException("whereIsWithCredentials"); } @Override public void start() { // no-op } @Override public void stop() { command.destroy(); } @Override public void listenOn(int port) { throw new UnsupportedOperationException("listenOn"); } @Override public void listenSecurelyOn(int port) { throw new UnsupportedOperationException("listenSecurelyOn"); } }; }
From source file:io.appium.java_client.service.local.AppiumDriverLocalService.java
License:Apache License
private void ping(long time, TimeUnit timeUnit) throws UrlChecker.TimeoutException { URL url = getUrl();//from ww w . j a v a 2s . co m try { URL status = new URL(url.toString() + "/status"); new UrlChecker().waitUntilAvailable(time, timeUnit, status); } catch (MalformedURLException e) { throw new RuntimeException( "There is something wrong with the URL " + url.toString().toString() + "/status"); } }
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);//from ww w .j a v a2 s.com 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) { } } }