8

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.

5
  • Have you installed appium server in your system? you must install appium server manually. Commented Jan 3, 2019 at 8:00
  • Installed already lol
    – nicholas
    Commented Jan 3, 2019 at 8:03
  • can you post your error log? Commented Jan 3, 2019 at 8:04
  • Did you installed node.js in your system? Do npm -v shows npm version? If it is not showing the version then you must add the nodejs path in the system variable Commented Jan 4, 2019 at 4:33
  • Shows 6.4.1 version.
    – nicholas
    Commented Jan 4, 2019 at 8:01

4 Answers 4

7

Try installing Appium globally. This resolved the issue for me.

npm install -g appium

0
0

I faced the same issue at my end

  1. Try to run the node server instance from command line, just type "node" and enter -- server should get started
  2. Open another terminal window and just check if all details are been going good for the process running by doing "ps eww"
  3. The node process running should be displayed here
  4. Just kill the "node server", by typing "Killall node" on the same command window you did "ps eww"
  5. The "node"window will show the process terminated.

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)

0

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

0

• 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.