I tried to start the appium server programmatically but encounter error. How to resolve this issues? I have nodejs installed and appium installed and environemnt variable set properly. I"m using maven appium java client 6.1.0 and selenium 3.14.0. Please help. A billion thanks for your help.
Code:
try {
File appDir = new File(System.getProperty("user.dir"));
File app = new File(appDir, "..\\apk\\Flipkart.apk");
// apk Capabilities
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "Sony Xperia Z2");
caps.setCapability("BROWSER_NAME", "Android");
caps.setCapability("platformVersion", "6.0");
caps.setCapability(MobileCapabilityType.PLATFORM_NAME, Platform.ANDROID);
//caps.setCapability("udid", "WUJ01N4RQ3"); // DeviceId from "adb devices" command
caps.setCapability("platformName", "Android");
caps.setCapability("app", app.getAbsolutePath());
caps.setCapability("appPackage", "com.flipkart.android");
caps.setCapability("appActivity","com.flipkart.android.SplashActivity");
// Appium Capabilities
caps.setCapability("skipUnlock","true");
caps.setCapability("noReset","false");
appiumBuilder = new AppiumServiceBuilder();
appiumBuilder.withIPAddress("127.0.0.1");
appiumBuilder.usingPort(47233);
appiumBuilder.withCapabilities(caps);
appiumBuilder.withStartUpTimeOut(3, TimeUnit.MINUTES);
appiumBuilder.withLogFile(new File(System.getProperty("user.dir") + "\\log\\appium.log"));
appiumBuilder.withArgument(GeneralServerFlag.SESSION_OVERRIDE);
appiumBuilder.withArgument(GeneralServerFlag.LOG_LEVEL, "DEBUG");
appiumBuilder.withArgument(GeneralServerFlag.ASYNC_TRACE, "true");
appiumServer = AppiumDriverLocalService.buildService(appiumBuilder);
appiumServer.start();
//new URL("http://127.0.0.1:47233/wd/hub")
driver = new AndroidDriver<MobileElement>(appiumServer, caps);
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
} catch (Exception ex) {
LogManager.logger.log(Level.INFO, "Exception: " + ex.getMessage());
}
Error Log:
INFO: Exception: Invalid server instance exception has occured: There is no installed nodes! Please install node via NPM (https://www.npmjs.com/package/appium#using-node-js) or download and install Appium app (http://appium.io/downloads.html) Jan 03, 2019 3:52:12 PM com.peterwkc.testManager.AndroidManager tearDown INFO: Exception: null
EDIT: I believe appium source code cannot detect my installation of nodejs and appium.
Try installing Appium globally. This resolved the issue for me.
npm install -g appium
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With