public AppiumServiceBuilder() { usingPort(DEFAULT_APPIUM_PORT); withEnvironment(System.getenv()); }
/** * Adds a server argument. * * @param argument is an instance which contains the argument name. * @param value A non null string value. (Warn!!!) Boolean arguments have a special moment: * the presence of an arguments means "true". At this case an empty string * should be defined. * @return the self-reference. */ public AppiumServiceBuilder withArgument(ServerArgument argument, String value) { String argName = argument.getArgument().trim().toLowerCase(); if ("--port".equals(argName) || "-p".equals(argName)) { usingPort(Integer.valueOf(value)); } else if ("--address".equals(argName) || "-a".equals(argName)) { withIPAddress(value); } else if ("--log".equals(argName) || "-g".equals(argName)) { withLogFile(new File(value)); } else { serverArguments.put(argName, value); } return this; }
/** * Starts a local server. * * @return ip of a local host * @throws UnknownHostException when it is impossible to get ip address of a local host */ public static String startAppiumServer() throws UnknownHostException { service = new AppiumServiceBuilder() .usingPort(PORT).build(); service.start(); InetAddress inetAddress = InetAddress.getLocalHost(); return inetAddress.getHostAddress(); }
public AppiumServiceBuilder() { usingPort(DEFAULT_APPIUM_PORT); withEnvironment(System.getenv()); }
/** * Adds a server argument. * * @param argument is an instance which contains the argument name. * @param value A non null string value. (Warn!!!) Boolean arguments have a special moment: * the presence of an arguments means "true". At this case an empty string * should be defined. * @return the self-reference. */ public AppiumServiceBuilder withArgument(ServerArgument argument, String value) { String argName = argument.getArgument().trim().toLowerCase(); if ("--port".equals(argName) || "-p".equals(argName)) { usingPort(Integer.valueOf(value)); } else if ("--address".equals(argName) || "-a".equals(argName)) { withIPAddress(value); } else if ("--log".equals(argName) || "-g".equals(argName)) { withLogFile(new File(value)); } else { serverArguments.put(argName, value); } return this; }
/** * @author wasiq.bhamla * @since Oct 27, 2017 12:42:30 PM */ private void setPort () { if (this.setting.getPort () > 0) { this.builder = this.builder.usingPort (this.setting.getPort ()); } else { this.builder = this.builder.usingAnyFreePort (); } } }
serBuilder=new AppiumServiceBuilder().withAppiumJS(new File("/usr/local/lib/node_modules/appium/build/lib/main.js")).usingPort(7000); service = serBuilder.build(); service.start();