question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error start Appium Server programmmatically

See original GitHub issue

The problem

Cannot instantiate Appium server programmatically on Ms Window 10 even install nodejs and appium 1.10.

Environment

  • Appium version (or git revision) that exhibits the issue: 1.10
  • Last Appium version that did not exhibit the issue (if applicable): NA
  • Desktop OS/version used to run Appium: 1.10
  • Node.js version (unless using Appium.app|exe):
  • Mobile platform/version under test: Android 6
  • Real device or emulator/simulator: Real Device
  • Appium CLI or Appium.app|exe:

Details

Cannot start Appium server programmatically but can start server from Appium GUI.

Link to Appium logs

[RemoteTestNG] detected TestNG version 6.14.3 C:\Users\kwong\Workspace\Appium\appiumjs\main.js:4 import { init as logsinkInit } from ‘./logsink’; ^

SyntaxError: Unexpected token { at new Script (vm.js:79:7) at createScript (vm.js:251:10) at Object.runInThisContext (vm.js:303:10) at Module._compile (internal/modules/cjs/loader.js:657:28) at Object.Module._extensions…js (internal/modules/cjs/loader.js:700:10) at Module.load (internal/modules/cjs/loader.js:599:32) at tryModuleLoad (internal/modules/cjs/loader.js:538:12) at Function.Module._load (internal/modules/cjs/loader.js:530:3) at Function.Module.runMain (internal/modules/cjs/loader.js:742:12) at startup (internal/bootstrap/node.js:283:19) Jan 04, 2019 9:17:20 AM com.peterwkc.manager.AndroidDriverManager setup INFO: Exception: The local appium server has not been started. The given Node.js executable: C:\Program Files\nodejs\node.exe Arguments: [C:\Users\kwong\Workspace\Appium.\appiumjs\main.js, --port, 39074, --address, 127.0.0.1, --log, C:\Users\kwong\Workspace\Appium\log\appium.log, --log-level, DEBUG, --async-trace, true, --session-override, --default-capabilities, {"app": "C:/Users/kwong/Workspace/Appium/…/apk/Flipkart.apk", "appActivity": "com.flipkart.android.SplashActivity", "appPackage": "com.flipkart.android", "deviceName": "Sony Xperia Z2", "noReset": "false", "platformName": "Android", "platformVersion": "6.0", "skipUnlock": "true"}] Process output: C:\Users\kwong\Workspace\Appium\appiumjs\main.js:4 import { init as logsinkInit } from ‘./logsink’; ^ SyntaxError: Unexpected token { at new Script (vm.js:79:7) at createScript (vm.js:251:10) at Object.runInThisContext (vm.js:303:10) at Module._compile (internal/modules/cjs/loader.js:657:28) at Object.Module._extensions…js (internal/modules/cjs/loader.js:700:10) at Module.load (internal/modules/cjs/loader.js:599:32) at tryModuleLoad (internal/modules/cjs/loader.js:538:12) at Function.Module._load (internal/modules/cjs/loader.js:530:3) at Function.Module.runMain (internal/modules/cjs/loader.js:742:12) at startup (internal/bootstrap/node.js:283:19)

Jan 04, 2019 9:17:20 AM com.peterwkc.testManager.AndroidManager tearDown INFO: Exception: null

Not produce.

Code To Reproduce Issue [ Good To Have ]

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.withAppiumJS(new File(".\\appiumjs\\main.js"));
	        appiumBuilder.usingDriverExecutable(new File("C:\\Program Files\\nodejs\\node.exe"));
	        appiumBuilder.withIPAddress("127.0.0.1");
	        appiumBuilder.usingAnyFreePort();
	        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());
		}

Please help. A billion thanks in advance.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mykola-mokhnachcommented, Jan 5, 2019

Try to uninstall the stuff completely via npm and then install it again. Also make sure the node version in PATH is the correct one (>= 8.0)

0reactions
lock[bot]commented, Jan 7, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to start Appium server programmatically - Stack Overflow
I am trying to start the Appium server using Appium service builder but am getting the following error. I tried everything but still...
Read more >
Cant launch and run Appium server programmatically with C#
Im trying to launch appium and run the server programmatically with C# but I cant get it working I can launch ... Additional...
Read more >
Unable to run Appium server programmatically #252 - GitHub
Hi,. I have posted detailed explanation on starting and stopping Appium server with java code which works in windows as well as in...
Read more >
How to start Appium Server Programmatically? - Medium
I have been using and working with Appium — Mobile automation framework however I was using Cloud Platform Service — LambdaTest to run...
Read more >
Running Appium Server Programmatically - 14 - QTPselenium
usage: C:\Users\Kenne\AppData\Roaming\npm\node_modules\appium\build\lib\main. ... js: error: argument -dc/--default-capabilities: invalid parseDefaultCaps value: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found