List of usage examples for org.openqa.selenium.net NetworkUtils NetworkUtils
public NetworkUtils()
From source file:com.mycompany.myproject.utilities.server.TestServerUtils.java
License:Apache License
private static void createServer() { serverPort = PortProber.findFreePort(); localIP = new NetworkUtils().getPrivateLocalAddress(); initServer(); }
From source file:com.opera.core.systems.environment.webserver.WebbitAppServer.java
License:Apache License
/** * Gets the hostname of this machine. By default it will attempt to retrieve the non-loopback * address so that remote browsers can connect to the web server, but in the event that this * fails, we will fall back to the internal loopback address. * * The hostname can be overriden using the {@link #HOSTNAME_FOR_TEST_ENV_NAME} environmental * variable.// w w w .ja v a 2 s . c o m * * @return hostname to use for web server */ private static String detectHostname() { String hostnameFromProperty = System.getenv(HOSTNAME_FOR_TEST_ENV_NAME); if (hostnameFromProperty != null) { return hostnameFromProperty; } NetworkUtils networkUtils = new NetworkUtils(); try { return networkUtils.getNonLoopbackAddressOfThisMachine(); } catch (WebDriverException e) { return networkUtils.getIpOfLoopBackIp4(); } }
From source file:org.openqa.grid.common.RegistrationRequest.java
License:Apache License
private static String guessHost(String host) { if ("ip".equalsIgnoreCase(host)) { NetworkUtils util = new NetworkUtils(); return util.getIp4NonLoopbackAddressOfThisMachine().getHostAddress(); } else if ("host".equalsIgnoreCase(host)) { NetworkUtils util = new NetworkUtils(); return util.getIp4NonLoopbackAddressOfThisMachine().getHostName(); } else {/* w w w . jav a 2 s . c o m*/ return host; } }
From source file:org.openqa.grid.web.Hub.java
License:Apache License
public Hub(GridHubConfiguration config) { Level logLevel = config.isDebug() ? Level.FINE : Level.INFO; Logger.getLogger("").setLevel(logLevel); for (Handler handler : Logger.getLogger("").getHandlers()) { Logger.getLogger("").removeHandler(handler); }/*from w w w . j a v a 2s. c om*/ String logFilename = config.getLogFilename() == null ? RemoteControlConfiguration.getDefaultLogOutFile() : config.getLogFilename(); if (logFilename != null) { try { Handler logFile = new FileHandler(new File(logFilename).getAbsolutePath(), true); logFile.setFormatter(new TerseFormatter(true)); logFile.setLevel(logLevel); Logger.getLogger("").addHandler(logFile); } catch (IOException e) { throw new RuntimeException(e); } } else { Handler console = new ConsoleHandler(); console.setLevel(logLevel); Logger.getLogger("").addHandler(console); } registry = Registry.newInstance(this, config); if (config.getHost() != null) { host = config.getHost(); } else { NetworkUtils utils = new NetworkUtils(); host = utils.getIp4NonLoopbackAddressOfThisMachine().getHostAddress(); } this.port = config.getPort(); for (String s : config.getServlets()) { Class<? extends Servlet> servletClass = ExtraServletUtil.createServlet(s); if (servletClass != null) { String path = "/grid/admin/" + servletClass.getSimpleName() + "/*"; log.info("binding " + servletClass.getCanonicalName() + " to " + path); addServlet(path, servletClass); } } initServer(); }
From source file:org.senchalabs.gwt.gwtdriver.gxt.models.BaseTest.java
License:Apache License
@Before public void startBrowser() { String url = System.getProperty("webdriver.remote.server"); Capabilities c = DesiredCapabilities.chrome(); driver = new RemoteWebDriver(c); // driver = new FirefoxDriver(); driver.manage().timeouts().setScriptTimeout(1000, TimeUnit.MILLISECONDS); driver.get("http://" + new NetworkUtils().getNonLoopbackAddressOfThisMachine() + ":9080/app/index.html?" + getScenarioName());//from ww w.j a va 2s . co m }