Reputation: 2770
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.
Upvotes: 8
Views: 12277
Reputation:
• Sometimes, when using Node Version Manager like nvm being used to install and maintain node and npm, you may need to download and install the same or higher version of node/npm being downloaded(in pkg form) from nodejs.org and update your PATH accordingly.
Upvotes: 0
Reputation: 617
I got the same problem when using nvm
although node
already installed on all versions.
Finally, I decided to uninstall nvm and it's worked with the only node
version
Upvotes: 0
Reputation: 853
Try installing Appium globally. This resolved the issue for me.
npm install -g appium
Upvotes: 7
Reputation: 327
I faced the same issue at my end
Time for the truth, run your script and all should get going smoothly
I did this with appium - 1.9.0 node - 11.9.0 npm version - 6.5.0 testscript - Java tool - Eclipse platform - iOS (10.14)
Upvotes: 0