Example usage for org.openqa.selenium.net NetworkUtils getNonLoopbackAddressOfThisMachine

List of usage examples for org.openqa.selenium.net NetworkUtils getNonLoopbackAddressOfThisMachine

Introduction

In this page you can find the example usage for org.openqa.selenium.net NetworkUtils getNonLoopbackAddressOfThisMachine.

Prototype

public String getNonLoopbackAddressOfThisMachine() 

Source Link

Document

Used by the mobile emulators that refuse to access localhost or 127.0.0.1 The IP4/IP6 requirements of this method are as-of-yet unspecified, but we return the string that is associated with the IP4 interface

Usage

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 ww.  j  av  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();
    }
}