appium: Unable to run Appium 1.5 using AppiumDriverLocalService

The problem

Installed Appium 1.5 using NPM and tried running it with AppiumDriverLocalService. I wasn’t able to run Appium server. Though same worked fine with Appium version 1.4.16.

Environment

  • Appium version (or git revision) that exhibits the issue: 1.5.0
  • Last Appium version that did not exhibit the issue (if applicable): 1.4.16
  • Desktop OS/version used to run Appium: Mac OS X El Capitan
  • Node.js version (unless using Appium.app|exe): v5.5
  • Mobile platform: Android/iOS
  • Real Device

Details

Code Used: AppiumDriverLocalService service = AppiumDriverLocalService.buildService(new AppiumServiceBuilder().withStartUpTimeOut(5, TimeUnit.SECONDS)); service.start(); driver=new AndroidDriver(capabilities);

Appium Path:/usr/local/lib/node_modules/appium

Link to Appium logs

Error on Eclipse: io.appium.java_client.service.local.InvalidServerInstanceException: 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) at io.appium.java_client.service.local.AppiumServiceBuilder.findNodeInCurrentFileSystem(AppiumServiceBuilder.java:107) at io.appium.java_client.service.local.AppiumServiceBuilder.checkAppiumJS(AppiumServiceBuilder.java:242) at io.appium.java_client.service.local.AppiumServiceBuilder.createArgs(AppiumServiceBuilder.java:248) at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:299) at io.appium.java_client.service.local.AppiumDriverLocalService.buildService(AppiumDriverLocalService.java:194) at guide_config.Setup.setupAppium(Setup.java:53) at guide_testcases.E2E_Tests.beforeTest(E2E_Tests.java:196) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84) at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138) at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:175) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:107) at org.testng.TestRunner.privateRun(TestRunner.java:767) at org.testng.TestRunner.run(TestRunner.java:617) at org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at org.testng.SuiteRunner.run(SuiteRunner.java:240) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224) at org.testng.TestNG.runSuitesLocally(TestNG.java:1149) at org.testng.TestNG.run(TestNG.java:1057) at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175) Caused by: java.io.IOException: /usr/local/lib/node_modules

at io.appium.java_client.service.local.AppiumServiceBuilder.findNodeInCurrentFileSystem(AppiumServiceBuilder.java:110)
... 30 more

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 15 (5 by maintainers)

Most upvoted comments

@mayureshshirodkar

AppiumServiceBuilder builder = new AppiumServiceBuilder()
                .withAppiumJS(new File("/usr/local/lib/node_modules/appium/build/lib/main.js"))
                .withArgument(GeneralServerFlag.APP, System.getProperty("user.dir") + "/build/wordpress.apk")
                .withArgument(GeneralServerFlag.LOG_LEVEL, "info")
                .withLogFile(new File(System.getProperty("user.dir") + "/target/logs/sample.txt"))
                .usingAnyFreePort()
        /* and so on */;
        appiumDriverLocalService = builder.build();
        appiumDriverLocalService.start();

You can also set appium server path when your starting the server, you don’t need to set in ENV variables

@SrinivasanTarget Looks like AppiumLocalService din’t pick up the default path to the main.js. It still pointed to appium.js whereas for Appium 1.5, it should have picked up main.js.

I had to set a environmental variable APPIUM_BINARY_PATH in my Eclipse Environment to ‘/usr/local/lib/node_modules/appium/build/lib/main.js’ and this worked for me.

@saikrishna321 : Your solution worked for me. Thank you very much AppiumServiceBuilder builder = new AppiumServiceBuilder() .withAppiumJS(new File(“/usr/local/lib/node_modules/appium/build/lib/main.js”)) .withArgument(GeneralServerFlag.LOG_LEVEL, “info”) .usingAnyFreePort()

    appiumService = builder.build();
    appiumService.start();
    appiumServiceUrl = appiumService.getUrl().toString();
    System.out.println("Appium Service Address : - "+ appiumServiceUrl);

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("appium-version", "1.3.2");
    capabilities.setCapability("platformName", "android");
    capabilities.setCapability("deviceName", "Pixel_4548");
    capabilities.setCapability(CapabilityType.VERSION, "8.1.0");
    capabilities.setCapability("appPackage", "com.ebay.mobile");
    capabilities.setCapability("appActivity", "com.ebay.mobile.activities.MainActivity");

    // Set job name
    //capabilities.setCapability("name", "Appium Sample" + date);
    //String appPath = System.getenv("android_app_path");
    //assert appPath != null: "Path to Android app is not set";
    //System.out.println("Android App path: "+ appPath);
    //capabilities.setCapability("app", appPath);
    driver = new AndroidDriver(new URL(appiumServiceUrl), capabilities);

    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);