Unable to start appium service by AppiumDriverLocalSerivce

Hi Guys,

Now i am trying to use page object model to design my selenium + appium framework. I wan to start the Appium service by AppiumDriverLocalService. The code like below:

    package org.longan.pom.demo;

import io.appium.java_client.service.local.AppiumDriverLocalService;

import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class StartAppium {

	private AppiumDriverLocalService service;
	
	@BeforeClass
	public void setUp() {
		service = AppiumDriverLocalService.buildDefaultService();
		service.start();
	}
	
	@Test
	public void getAppiumState() {
		System.out.println(service.isRunning());
	}
	
	@AfterClass
	public void tearDown() {
		service.stop();
	}
}

However, i got some errors like below. i installed appium by npm and of course i installed node.

io.appium.java_client.service.local.InvalidNodeJSInstance: Node.js is not installed
	at io.appium.java_client.service.local.AppiumServiceBuilder.validateNodeJSVersion(AppiumServiceBuilder.java:87)
	at io.appium.java_client.service.local.AppiumServiceBuilder.findDefaultExecutable(AppiumServiceBuilder.java:137)
	at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:290)
	at io.appium.java_client.service.local.AppiumDriverLocalService.buildService(AppiumDriverLocalService.java:160)
	at io.appium.java_client.service.local.AppiumDriverLocalService.buildDefaultService(AppiumDriverLocalService.java:156)
	at org.longan.pom.demo.StartAppium.setUp(StartAppium.java:15)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
	at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:510)
	at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:211)
	at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
	at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:170)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:104)
	at org.testng.TestRunner.privateRun(TestRunner.java:773)
	at org.testng.TestRunner.run(TestRunner.java:623)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
	at org.testng.SuiteRunner.run(SuiteRunner.java:259)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)
	at org.testng.TestNG.run(TestNG.java:1018)
	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: Cannot run program "node": error=2, No such file or directory
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
	at java.lang.Runtime.exec(Runtime.java:620)
	at java.lang.Runtime.exec(Runtime.java:450)
	at java.lang.Runtime.exec(Runtime.java:347)
	at io.appium.java_client.service.local.AppiumServiceBuilder.validateNodeJSVersion(AppiumServiceBuilder.java:83)
	... 29 more
Caused by: java.io.IOException: error=2, No such file or directory
	at java.lang.UNIXProcess.forkAndExec(Native Method)
	at java.lang.UNIXProcess.<init>(UNIXProcess.java:248)
	at java.lang.ProcessImpl.start(ProcessImpl.java:134)
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
	... 33 more

Hope can get some help on this case.

1 Like

How are you running these tests? If it’s from the command line, you need to add node to your path. You can check if node is in your path by typing ‘which node’ in a terminal (there are plenty of other ways, this one is quickest & easiest IMHO). Here are some instructions for adding to the path on 10.10, which is the latest OS X version (If you are using an earlier version, you may need to google search for more instructions):

http://coolestguidesontheplanet.com/add-shell-path-osx/

But perhaps you are running these tests in an IDE. You may need to explicitly tell your IDE to use the $PATH environment variable. For example, here are some instructions for Eclipse:

http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Fconcepts%2Fcpathvars.htm

Once again, you may need to use google search if your IDE is not Eclipse.

Hopefully one of these will help you.

1 Like

@wreed Thanks. Like you said, i am using Eclipse to run these tests. i am going to take a look the instructions for eclipse.

And As you can see in attachment, once i got the correct path, can i just type code like below ?

service = AppiumDriverLocalService.buildDefaultService();
service.start();
iosDriver = new IOSDriver<MobileElement>(service.getUrl(), capabilities);

No more need to specify the URL like

new IOSDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

Am i right ?

2 Likes

No, we are just trying to fix this error:

Once you have the path set in Eclipse you should be able to start Appium properly. You’ll probably always have to set the URL.

Thanks @wreed, i am trying to reference below issue to start appium by programmatically and set AppiumDriverLocalService.

One more thing please, i still don’t understand why we need AppiumDriverLocalService ? When should we use this object ?

@suroit

The thread you are following is JAVA programming way to start appium server. It is bit complex and more prone to errors …

But AppiumDriverLocalService is a new feature implemented by appium guys in java client 3.2 to start appium server using appium library itself instead of using JAVA.

so wreed is basically saying when you use this new feature it is must to have node.js to be installed on u r system.
same error you are getting.

So first install node.js on your system then you can try with below code. It works fine on android for me.

In this way appium library just wants to know where is node.exe in u r system and where is appium.js file in ur system. appium.js file will be inside the appium server you downloaded and node.exe will be in programfiles like other installed programs.

AppiumDriverLocalService service = AppiumDriverLocalService
.buildService(new AppiumServiceBuilder()
.usingDriverExecutable(new File(“C:/Program Files/nodejs/node.exe”))
.withAppiumJS(new File(“C:/Users/Desktop/android/AppiumForWindows-1.3.4.1/Appium/node_modules/appium/bin/appium.js”))
.withLogFile(new File(“C:/Users/amit.ja/AppiumServerLogs.txt”))
.withIPAddress(“127.0.0.1”)
.usingPort(4725));
service.start();

Hope this Helps !!!

3 Likes

Thanks @amitjaincoer191. i have successful to start the Appium service by AppiumDriverLocalService on MAC. The code lists as below:

public class StartAppium {

	private IOSDriver<MobileElement> iosDriver;
	private AppiumDriverLocalService service;

	@BeforeClass
	public void setUp() throws Exception {

		service = AppiumDriverLocalService
				.buildService(new AppiumServiceBuilder()
						.usingDriverExecutable(new File("/usr/local/bin/node"))
						.withAppiumJS(
								new File(
										"/usr/local/lib/node_modules/appium/bin/appium.js"))
						.withIPAddress("127.0.0.1").usingPort(4723));

		service.start();

		DesiredCapabilities capabilities = DesiredCapabilities.iphone();
		capabilities.setCapability("platformName", "IOS");
		capabilities.setCapability("deviceName", "iPhone Simulator");
		capabilities.setCapability("platformVersion", "9.0");
		capabilities.setCapability("browserName", "Safari");

		iosDriver = new IOSDriver<MobileElement>(service.getUrl(), capabilities);
		iosDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
	}

	@Test
	public void getAppiumStatus() {
		iosDriver.navigate().to("http://www.baidu.com");
		iosDriver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
		iosDriver.findElementByName("wd").sendKeys("appium desired capability");
		iosDriver.findElement(By.name("wd")).clear();
	}

	@AfterClass
	public void tearDown() {
		iosDriver.quit();
		service.stop();
	}
}
3 Likes

Another question on this, what about if i want to assign a nodeConfig file to the appium server ?

I have tried, but i have no idea which method should i use…

Would you please help to give me some example or some hints ?

Thanks a lot

Hi guys,

Do you have any idea on how to assign nodeconfig file to appium by AppiumDriverLocalService ?

@amitjaincoer191,@wreed

Thanks

1 Like

Thanks guys, i have solved this issue. i checked with API and found

withArgument(GeneralServerFlag.CONFIGURATION_FILE, "")

can assign a configuration file.

Appreciate for your help on this topic.

@suroit

Are u using grid nodeconfig.json file using this option ?

If yes Can u tell me one more thing …

So for grid you used this code multiple times to register a node to a running grid HUB ???

Hi @amitjaincoer191,

Yes, i register appium as a node to Selenium Grid. The grid is the HUB.

But i don’t try it multiple times.

Is there anything wrong on this ?

@suroit and @amitjaincoer191,

I got below error when I try with the @suroit code. As per the console error, it is saying ideviceinstaller is not installed on mac. But I have installed and it is alreary exist in my mac. Could u please help me to get rid of this errors.

[TestNG] Running:
/private/var/folders/jx/ffh_slbj46l55xd0wqb7j7sc0000gp/T/testng-eclipse–385757555/testng-customsuite.xml

e[36minfoe[39m: Welcome to Appium v1.4.13 (REV c75d8adcb66a75818a542fe1891a34260c21f76a)
e[36minfoe[39m: Appium REST http interface listener started on 127.0.0.1:4723
e[36minfoe[39m: [debug] Non-default server args: {“address”:“127.0.0.1”,“log”:"/Users/mahesh/Documents/automation/VideoRecording/logs.txt"}
e[36minfoe[39m: Console LogLevel: debug
e[36minfoe[39m: File LogLevel: debug
e[36minfoe[39m: e[37m–>e[39m e[37mGETe[39m e[37m/wd/hub/statuse[39m e[90m{}e[39m
e[36minfoe[39m: [debug] Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.4.13”,“revision”:“c75d8adcb66a75818a542fe1891a34260c21f76a”}}}
e[36minfoe[39m: e[37m<-- GET /wd/hub/status e[39me[32m200e[39me[90m 8.936 ms - 105e[39m e[90m{“status”:0,“value”:{“build”:{“version”:“1.4.13”,“revision”:“c75d8adcb66a75818a542fe1891a34260c21f76a”}}}e[39m
e[36minfoe[39m: e[37m–>e[39m e[37mPOSTe[39m e[37m/wd/hub/sessione[39m e[90m{“desiredCapabilities”:{“app”:"/Users/mahesh/Downloads/ShureMotivPreview-3.ipa",“browserName”:"",“platformName”:“iOS”,“udid”:“39e1f150b412544633088c913f117be93a846b67”,“deviceName”:""}}e[39m
e[36minfoe[39m: Client User-Agent string: Apache-HttpClient/4.5.1 (Java/1.8.0_45)
e[36minfoe[39m: [debug] Using local .ipa from desired caps: /Users/mahesh/Downloads/ShureMotivPreview-3.ipa
e[36minfoe[39m: [debug] Copying local zip to tmp dir
e[36minfoe[39m: [debug] /Users/mahesh/Downloads/ShureMotivPreview-3.ipa copied to /var/folders/jx/ffh_slbj46l55xd0wqb7j7sc0000gp/T/115113-8681-1te72y6/appium-app.zip
e[36minfoe[39m: [debug] Unzipping /var/folders/jx/ffh_slbj46l55xd0wqb7j7sc0000gp/T/115113-8681-1te72y6/appium-app.zip
e[36minfoe[39m: [debug] Testing zip archive: /var/folders/jx/ffh_slbj46l55xd0wqb7j7sc0000gp/T/115113-8681-1te72y6/appium-app.zip
e[36minfoe[39m: [debug] Zip archive tested clean
e[36minfoe[39m: [debug] Unzip successful
e[36minfoe[39m: [debug] Using locally extracted app: /var/folders/jx/ffh_slbj46l55xd0wqb7j7sc0000gp/T/115113-8681-1te72y6/Payload/ShureMotiv.app
e[36minfoe[39m: [debug] Creating new appium session 155dcc2e-24f4-4b26-b037-1cb4a83e4554
e[36minfoe[39m: [debug] Removing any remaining instruments sockets
e[36minfoe[39m: [debug] Cleaned up instruments socket /tmp/instruments_sock
e[36minfoe[39m: [debug] Auto-detecting iOS udid…
e[36minfoe[39m: [debug] Not auto-detecting udid, running on sim
e[36minfoe[39m: [debug] Could not parse plist file (as binary) at /var/folders/jx/ffh_slbj46l55xd0wqb7j7sc0000gp/T/115113-8681-1te72y6/Payload/ShureMotiv.app/en.lproj/Localizable.strings
e[36minfoe[39m: Will try to parse the plist file as XML
e[36minfoe[39m: [debug] Could not parse plist file (as XML) at /var/folders/jx/ffh_slbj46l55xd0wqb7j7sc0000gp/T/115113-8681-1te72y6/Payload/ShureMotiv.app/en.lproj/Localizable.strings
e[33mwarne[39m: Could not parse app Localizable.strings assuming it doesn’t exist
e[36minfoe[39m: [debug] Getting bundle ID from app
e[36minfoe[39m: [debug] Parsed app Info.plist (as binary)
e[36minfoe[39m: [debug] Creating instruments
e[36minfoe[39m: [debug] Preparing uiauto bootstrap
e[36minfoe[39m: [debug] Dynamic bootstrap dir: /Users/mahesh/Library/Application Support/appium/bootstrap
e[36minfoe[39m: [debug] Dynamic env: {“nodePath”:"/Applications/Appium.app/Contents/Resources/node/bin/node",“commandProxyClientPath”:"/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js",“instrumentsSock”:"/tmp/instruments_sock",“interKeyDelay”:null,“justLoopInfinitely”:false,“autoAcceptAlerts”:false,“autoDismissAlerts”:false,“sendKeyStrategy”:“grouped”}
…6minfoe[39m: [debug] Dynamic bootstrap code: // This file is automatically generated. Do not manually modify!
e[36minfoe[39m: [debug] Dynamic bootstrap path: /Users/mahesh/Library/Application Support/appium/bootstrap/bootstrap-5b08b331b944fae5.js
e[36minfoe[39m: [debug] Reusing dynamic bootstrap: /Users/mahesh/Library/Application Support/appium/bootstrap/bootstrap-5b08b331b944fae5.js
e[36minfoe[39m: [debug] Attempting iOS device log capture via libimobiledevice idevicesyslog
e[33mwarne[39m: Could not capture device log using libimobiledevice idevicesyslog. Libimobiledevice probably isn’t installed
e[36minfoe[39m: [debug] Attempting iOS device log capture via deviceconsole
e[36minfoe[39m: [debug] Creating iDevice object with udid 39e1f150b412544633088c913f117be93a846b67
e[36minfoe[39m: [debug] Couldn’t find ideviceinstaller, trying built-in at /Applications/Appium.app/Contents/Resources/node_modules/appium/build/libimobiledevice-macosx/ideviceinstaller
e[31merrore[39m: Could not initialize ideviceinstaller; make sure it is installed and works on your system
e[36minfoe[39m: [debug] Cleaning up appium session
e[31merrore[39m: Failed to start an Appium session, err was: Error: Could not initialize ideviceinstaller; make sure it is installed and works on your system
e[36minfoe[39m: [debug] Error: Could not initialize ideviceinstaller; make sure it is installed and works on your system
at [object Object].IOS.getIDeviceObj (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/ios/ios.js:909:13)
at [object Object].IOS.installToRealDevice (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/ios/ios.js:856:32)
at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js:607:21
at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js:246:17
at iterate (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js:146:13)
at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js:157:25
at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js:248:21
at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js:612:34
at [object Object]. (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/ios/ios-crash-log.js:52:5)
at [object Object]. (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/ios/ios-crash-log.js:27:5)
at f (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/glob/node_modules/once/once.js:17:25)
at Glob. (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/glob/glob.js:131:7)
at Glob.emit (events.js:107:17)
at Glob._finish (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/glob/glob.js:168:8)
at done (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/glob/glob.js:157:12)
at Glob._processReaddir2 (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/glob/glob.js:351:12)
at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/glob/glob.js:288:17
at RES (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/glob/node_modules/inflight/inflight.js:23:14)
at f (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/glob/node_modules/once/once.js:17:25)
at Glob._readdirEntries (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/glob/glob.js:480:10)
at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/glob/glob.js:457:12
at FSReqWrap.oncomplete (fs.js:95:15)
e[36minfoe[39m: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Could not initialize ideviceinstaller; make sure it is installed and works on your system)”,“origValue”:“Could not initialize ideviceinstaller; make sure it is installed and works on your system”},“sessionId”:null}
e[36minfoe[39m: e[37m<-- POST /wd/hub/session e[39me[31m500e[39me[90m 2030.939 ms - 300e[39m e[90me[39m
FAILED: findings
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Could not initialize ideviceinstaller; make sure it is installed and works on your system) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2.23 seconds
Build info: version: ‘2.48.2’, revision: ‘41bccdd’, time: ‘2015-10-09 19:59:12’
System info: host: ‘pcnicmcdev01’, ip: ‘172.25.11.76’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.11’, java.version: ‘1.8.0_45’
Driver info: io.appium.java_client.ios.IOSDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.ios.IOSDriver.execute(IOSDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:247)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:129)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:142)
at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:37)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:160)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:168)
at io.appium.java_client.ios.IOSDriver.(IOSDriver.java:56)
at video.NewTest.findings(NewTest.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:821)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1131)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:773)
at org.testng.TestRunner.run(TestRunner.java:623)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
at org.testng.SuiteRunner.run(SuiteRunner.java:259)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)
at org.testng.TestNG.run(TestNG.java:1018)
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)

===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0

===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0

[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@39ed3c8d: 29 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 7 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@762efe5d: 13 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@75a1cd57: 26 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@6504e3b2: 44 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@182decdb: 26 ms

Just having ideviceinstaller on the Mac doesn’t mean it shows on your $PATH. Try this command:
which ideviceinstaller

That will tell you if it’s on your $PATH. If it’s not, here is a tutorial on adding to the $PATH on OS X:

There are many more like it a mere google search away.

Hello friend,

Please use the way I explained in method-1 in my post, it will help you.

Thanks,
Aswini Kumar
http://in.linkedin.com/in/aksahu1

Hi

I am getting below error while starting appium server using above method.
It would be great, if you can help to solve this issue.

I am using 1.4.16 appium version on Mac

io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException: The local appium server has not been started. The given Node.js executable: /usr/local/bin/node Arguments: [/usr/local/lib/node_modules/appium/bin/appium.js, --port, 32394, --address, 127.0.0.1, --udid, 192.168.59.101:5555, --log-level, warn:error:info, --chromedriver-port, 59215, --bootstrap-port, 59214, --no-reset, --nodeconfig, /Users/mayur_d/Test_Branch_3.12/target/test-classes/GridConfig.json, --session-override]

at io.appium.java_client.service.local.AppiumDriverLocalService.start(AppiumDriverLocalService.java:140)
at com.test.gridsetup.GridConfig$1.run(GridConfig.java:202)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Caused by: java.lang.NoClassDefFoundError: org/apache/commons/exec/DaemonExecutor
at org.openqa.selenium.os.UnixProcess.(UnixProcess.java:52)
at org.openqa.selenium.os.CommandLine.(CommandLine.java:38)
at io.appium.java_client.service.local.AppiumDriverLocalService.start(AppiumDriverLocalService.java:125)
… 4 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.exec.DaemonExecutor
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
… 7 more

Code i have written is
private void startAppiumServer(final Client client, final String nodeConfigFilePath) throws InterruptedException {
Logger.info(“Starting appium server”);

	executorService = Executors.newSingleThreadExecutor();
	executorService.execute(new Runnable() {
		public void run() {
			try {
				AppiumDriverLocalService driverLocalService = AppiumDriverLocalService
						.buildService(new AppiumServiceBuilder()
								.withAppiumJS(new File("/usr/local/lib/node_modules/appium/bin/appium.js"))
								.usingDriverExecutable(new File("/usr/local/bin/node")).withIPAddress("127.0.0.1")
								.usingAnyFreePort().withArgument(GeneralServerFlag.UIID, client.getSerialNo())
								.withArgument(AndroidServerFlag.BOOTSTRAP_PORT_NUMBER,
										"" + client.getBootstrapPort())
								.withArgument(GeneralServerFlag.CHROME_DRIVER_PORT,
										"" + client.getChromeDriverport())
								.withArgument(GeneralServerFlag.NO_RESET)
								.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
								.withArgument(GeneralServerFlag.LOG_LEVEL, "warn:error:info")
								.withArgument(GeneralServerFlag.CONFIGURATION_FILE, nodeConfigFilePath));
				Logger.info("Server url: " + driverLocalService.getUrl());
				driverLocalService.start();
			} catch (Exception e) {
				Logger.error("Failed to start appium server. ");
				e.printStackTrace();
			}
		}
	});
}

Hey. I got below error while following the above step:

/usr/local/lib/node_modules/appium/bin/appium.js:1
(function (exports, require, module, __filename, __dirname) { import _ from 'lodash’;
^^^^^^
SyntaxError: Unexpected token import
at Object.exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:513:28)
at Object.Module._extensions…js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Function.Module.runMain (module.js:575:10)
at startup (node.js:160:18)
at node.js:449:3

Hi, I got the error while following the same approach.

/usr/local/lib/node_modules/appium/bin/appium.js:1
(function (exports, require, module, __filename, __dirname) { import _ from 'lodash’;
^^^^^^
SyntaxError: Unexpected token import
at Object.exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:513:28)
at Object.Module._extensions…js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Function.Module.runMain (module.js:575:10)
at startup (node.js:160:18)
at node.js:449:3