String AppiumNodePath="C:\\Program Files\\Appium\\node.exe";
String AppiumJSPath="C:\\Program Files\\Appium\\node_modules\\appium\\bin\\appium.js";
AppiumDriverLocalService appiumInstance;
appiumInstance = AppiumDriverLocalService.buildService(new AppiumServiceBuilder().
usingAnyFreePort().usingDriverExecutable(new File(AppiumNodePath)).
withAppiumJS(new File( AppiumJSPath)));
appiumService.start();
Note:
- 'usingAnyFreePort()' which Configures the appium server to start on any available port.
- If we want to execute tests on any specific port, we have to use method 'usingPort(port value)' which sets the port on which appium server has to be started.