Error start Appium Server programmmatically
See original GitHub issueThe 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:
- Created 5 years ago
- Comments:10 (1 by maintainers)
Top GitHub Comments
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)
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.