i want to use AppiumServiceBuilder to build multiple AppiumServer,
(package io.appium.java_client.service.local)
AppiumServiceBuilder builder = new AppiumServiceBuilder()
builder.withIPAddress(ipAddress);
builder.usingPort(port);
builder.withUdid(udid);
but there is no method like builder.withUdid(udid) to use.
Appium version (or git revision) that exhibits the issue: 1.7.1
Java Client version: 5.0.4
Last Appium version that did not exhibit the issue (if applicable):
Desktop OS/version used to run Appium:
Node.js version (unless using Appium.app|exe): 5.4.2
Mobile platform/version under test:
Real device or emulator/simulator: real device
Appium CLI or Appium.app|exe:
that is:
devicesOne(udidOne) -->AppiumServerOne-->DriverOne
devicesTwo(udidTwo) -->AppiumServerTwo-->DriverTwo
devicesThree(udidThree) -->AppiumServerThree-->DriverThree
……
my question is how to use "udid" to launch different AppiumServer with AppiumServiceBuilder?
@smallsharp if you trying to run several tests in parallel on different devices UDID of those devices would be provided as part of the --default-capabilities '{"udid":"device_udid_goes_here"}' with CLI.
To set it using the code you need to pass it as .withCapabilities(DESIRE_CAPABILITIES).
But in addition to udid (for parallel execution), you'll need to have unique ports for appium, native ui and web ui communications with each device.
What I mean by this - is that (for example for Android) you'll need to run AppiumServer with .usingAnyFreePort().withArgument(AndroidServerFlag.BOOTSTRAP_PORT_NUMBER, driverPort).withArgument(AndroidServerFlag.CHROME_DRIVER_PORT, webPort)) parameters. Appium would generate random free port for the AppiumServer itself, but BOOTSTRAP_PORT_NUMBER and CHROME_DRIVER_PORT need to be found and set while AppiumServer building.
My service build looks like this for Android (for ios webPort need to be passed with IOSServerFlag.WEBKIT_DEBUG_PROXY_PORT argument and driver port should be set in capabilities setCapability(AllCapabilityType.WDA_LOCAL_PORT, driverPort)):
AppiumDriverLocalService.buildService(new AppiumServiceBuilder()
.withLogFile(appiumLogPath)
.usingDriverExecutable(driverExecutable)
.withAppiumJS(appiumJs)
.withIPAddress(ipAddress)
.usingAnyFreePort()
.withArgument(SESSION_OVERRIDE)
.withArgument(GeneralServerFlag.LOG_LEVEL, LOG_LEVEL_VALUE)
.withArgument(GeneralServerFlag.LOG_TIMESTAMP)
.withArgument(AndroidServerFlag.BOOTSTRAP_PORT_NUMBER, driverPort)
.withArgument(AndroidServerFlag.CHROME_DRIVER_PORT, webPort));
Please let me know if this answer your question ;)
Sorry for the late response.
@smallsharp Have you tried it to run on different/random ports?
Also there are options:
builder.withCapabilities(capabilities); //you can define udid here
@TikhomirovSergey @TikhomirovSergey
Thks very much , it works
DesiredCapabilities dc = new DesiredCapabilities();
dc.setCapability("udid", udid);
int driverPort = port + 1;
int webPort = port +4792;
AppiumDriverLocalService localService = AppiumDriverLocalService.buildService(new AppiumServiceBuilder()
.withLogFile(logFile)
// .usingDriverExecutable(driverExecutable)
// .withAppiumJS(appiumJs)
.withIPAddress(ipAddress)
// .usingAnyFreePort()
.usingPort(port)
.withCapabilities(dc)
.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
.withArgument(GeneralServerFlag.LOG_TIMESTAMP)
.withArgument(AndroidServerFlag.BOOTSTRAP_PORT_NUMBER, String.valueOf(driverPort))
.withArgument(AndroidServerFlag.CHROME_DRIVER_PORT, String.valueOf(webPort)));
Most helpful comment
@TikhomirovSergey @TikhomirovSergey
Thks very much , it works