This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
176 / 205
Jan 2017

@ dduphorn,

Maybe these informations will be help for you:

1) my installation before your 7 steps, was:
brew install node
sudo npm -g install ios-deploy --unsafe-perm=true
brew install ruby
gem install xcpretty
npm install appium
sudo npm install -g appium-doctor

my OLD patches after installation by brew:
/usr/local/bin/appium
/usr/local/bin/node

2) now I did your seven steps:
I didn't have NVM, so I installed it
nvm list
node -> stable (-> N/A) (default)
iojs -> N/A (default)
nvm install 6.0.0

and I have new patches:
/Users/me/.nvm/versions/node/v6.0.0/bin/appium
/Users/me/.nvm/versions/node/v6.0.0/bin/node

I paste this patches to eclipse, but still the same error:
[XCUITest] Error: Command 'idevice_id -l' errored out: Error: spawn idevice_id ENOENT

3) now, after new installation of Node and Appium
/Users/me/.nvm/versions/node/v6.0.0/bin/appium
/Users/me/.nvm/versions/node/v6.0.0/bin/node
I can't run IOSDriver on Eclipse, if appium is run on command line

with this patches in eclipse:
/usr/local/bin/appium
/usr/local/bin/node
I could do it.

4) maybe problem is in driver java code:
capabilities.setCapability and url, could you please show your code to start IOSDriver?

@wreed
Yes I have:
/usr/local/bin/idevice_id

Below is How I started the appium server

CommandLine command = new CommandLine("/Users/"+strAutomationUser+"/.nvm/versions/node/v6.0.0/bin/node");
command.addArgument("/Users/"+strAutomationUser+"/.nvm/versions/node/v6.0.0/bin/appium",false);
command.addArgument("--address", false);
command.addArgument("127.0.0.1");
command.addArgument("--port", false);
command.addArgument(strAppiumPort);
command.addArgument("-bp", false);
command.addArgument(strBootstrapPort);
command.addArgument("--full-reset", true);
command.addArgument("--session-override", true);
//command.addArgument("--no-reset", true);
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
try {executor.execute(command, resultHandler);
Thread.sleep(5000);System.out.println("Appium server started.");}
catch (IOException e)
{e.printStackTrace();}
catch (InterruptedException e)
{e.printStackTrace();}

//Capabilities
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("newCommandTimeout", 60 * 5);
capabilities.setCapability("platformName","iOS");
capabilities.setCapability("deviceName",strIOSDeviceName);
capabilities.setCapability("automationName","XCUITest");
capabilities.setCapability("udid",strIOSUdid);
capabilities.setCapability("deviceName",strIOSDeviceName+"("+strIOSUdid+")");
File f = new File(strIOSPath);
if(f.exists()) {capabilities.setCapability("app",strIOSPath);}
else{String strErrorMsg = "The IOS application path didn't exists ("+strIOSPath+")";Reporter.log(""+strErrorMsg+"");Assert.fail(strErrorMsg);return null;}
capabilities.setCapability("launchTimeout", 60000);
capabilities.setCapability("sendKeyStrategy","setValue");
IOSDriver iosdriver = new IOSDriver(new URL("http://127.0.0.1:"+strAppiumPort+"/wd/hub"), capabilities);

Hope that helps

DD

still the same :frowning:
[XCUITest] Error: Command 'idevice_id -l' errored out: Error: spawn idevice_id ENOENT

8 days later

these type of approaches always result in lots of issues as we need to think a lot and write lots of code hence better use AppiumDriverLocalService which is small and crispy.....it uses very less and excellent output besides helps to plug-in with other programs

HI Team,
@Hassan_Radi

I am trying to start appium server through java code but getting UnreachableBrowserException. I have posted my question on StackOverflow with all the code and logs. Please have a look and help.

Node.exe is started but i get exception during AndroidDriver initialization and node.exe is closed during the same.
NPM method is not working for me as I cannot install appium via npm due to network proxy settings in my office network.

check IP - > String url = "http://127.0.0.1:4723/wd/hub";

when your appium started what it is writing?

for example:
[Appium] Appium REST http interface listener started on 0.0.0.0:4723

U are starting the server by splitting the normal command into different strings I mean ip--->1 string, port---> another string ,etc.....which is always a big headache because of starting of the server requires certain parameters in the relevant sequence hence it's always better to use AppiumDriverLocalService in your program which is the best and efficient....there are lots of tutorials available and U can go through this http://aksahu.blogspot.in/2015/10/start-and-stop-appium-server.html41 which is one of the best for this purpose

Appium server launches every time whenever new scenario starts while using Cucumber-Selenium.
Please do help in resolving this issue.It will be very helpful!!!Thanks in Advance :slight_smile:

I am trying your suggestions on a Mac setup. I was able to start up the appium server programmatically but a driver session could not be made. When I dug into the logs it is complaining that the capabilities are not proper as deviceName can't be null. But I am setting deviceName in the desired capabilities. Any inputs on these.

EDIT : There was a silly error in my code and I was able to fix that but now I am getting a different error. Attaching logs.

[Appium] Welcome to Appium v1.6.3 (REV f58265b0c3d15444b3ed8b046a020724be683f63)
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"app":"/Users/vikumar/Desktop/ShareConnect.zip","platformVersion":"9.3","automationName":"XCUITest","platformName":"iOS","udid":"dd5287b0c2c5c9a86b3144e5f6dbaa646744b835","deviceName":"iPad","fullReset":true}}
[debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"app":"/Users/vikumar/Desktop/ShareConnect.zip","platformVersion":"9.3","automationName":"XCUITest","platformName":"iOS","udid":"dd5287b0c2c5c9a86b3144e5f6dbaa646744b835","deviceName":"iPad","fullReset":true},null,null,null,null]
[Appium] Creating new XCUITestDriver session
[Appium] Capabilities:
[Appium] app: '/Users/vikumar/Desktop/ShareConnect.zip'
[Appium] platformVersion: '9.3'
[Appium] automationName: 'XCUITest'
[Appium] platformName: 'iOS'
[Appium] udid: 'dd5287b0c2c5c9a86b3144e5f6dbaa646744b835'
[Appium] deviceName: 'iPad'
[Appium] fullReset: true
[debug] [XCUITest] XCUITestDriver version: 2.4.2
[BaseDriver] Session created with session id: 10f7e916-1665-48e0-a7f7-23b280ca2436
[debug] [XCUITest] Error: Could not get Xcode version. /Library/Developer/Info.plist does not exist on disk.
at getVersionWithoutRetry$ (lib/xcode.js:116:11)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as next
at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
Error: Could not get Xcode version. /Library/Developer/Info.plist does not exist on disk.
at getVersionWithoutRetry$ (lib/xcode.js:116:11)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as next
at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)

Don't see this error when I run appium from command prompt. My env is as follows :
Mac book pro (sierra), appium : 1.6.3, java 1.8

wonder if you have udid why you need set any device name... try without it.
also real reason in logs is - [debug] [XCUITest] Error: Could not get Xcode version. /Library/Developer/Info.plist does not exist on disk.

Hey! I could solve this problem by adding /usr/bin:/usr/local/bin in my eclipse path variable and that solved this problem. But again I have an issue. So, when I start appium and my test run completes, after that I am not getting any testng logs. I mean the summary after test run from testng is missing in my logs. Any ideas how to resolve it. So the following summary is missing

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

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

[TestNG] Time taken by org.testng.reporters.jq.Main@25618e91: 27 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@17d99928: 6 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@7bb11784: 5 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 0 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@483bf400: 58 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@34340fab: 4 ms

10 days later

Appium starts and stops @ [Appium] Appium REST http interface listener started on 0.0.0.0:4723

how do i move further to
[HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"app":"/Users/vikumar/Desktop/ShareConnect.zip","platformVersion":"9.3","automationName":"XCUITest","platformName":"iOS","udid":"dd5287b0c2c5c9a86b3144e5f6dbaa646744b835","deviceName":"iPad","fullReset":true}}

below is my command in jenkins(batch file)

this is my command
/usr/local/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/build/lib/main.js --address 0.0.0.0 --port 4723/wd/hub --app /Users/Shared/Jenkins/Home/jobs/MMLocalProject/workspace/src/T/result/MeasuringMaster.app --command-timeout 200000

[​] $ /bin/sh -xe /Users/Shared/Jenkins/tmp/hudson8130735449869040556.sh
+ cd /Users/Shared/Jenkins/Home/jobs/MMLocalProject/workspace/
+ chmod g+w+x appium.sh
+ sh appium.sh
[Appium] Welcome to Appium v1.5.3
[Appium] Non-default server args:
[Appium] defaultCommandTimeout: 200000
[Appium] app: '/Users/Shared/Jenkins/Home/jobs/MMLocalProject/workspace/src/T/result/MeasuringMaster.app'
[Appium] Deprecated server args:
[Appium] --app => --default-capabilities '{"app":"/Users/Shared/Jenkins/Home/jobs/MMLocalProject/workspace/src/T/result/MeasuringMaster.app"}'
[Appium] Default capabilities, which will be added to each request unless overridden by desired capabilities:
[Appium] app: '/Users/Shared/Jenkins/Home/jobs/MMLocalProject/workspace/src/T/result/MeasuringMaster.app'
[Appium] Appium REST http interface listener started on 0.0.0.0:4723

2 months later

Can anybody tell me how to pas the directory in as file string for mac ? i have tried diffrent ways but could not get it done.

1: private static String APPIUMSERVERSTART = "/bin/sh /Applications/Appium.app/Contents/Resources";
2: private static String APPIUMSERVERSTART="/Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js";
3: private static String APPIUMSERVERSTART = "/bin/sh /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js " ;
and passed to
File file = new (APPIUMSERVERSTART);
AppiumServer appiumServer = new AppiumServer(file, serverArguments);

but every time it adds /node/bin/node at the end of path and says can not find directory. I am using macOS. Any help would be appreciated.
@Hassan_Radi @Nitinvermaa1 @tovaibhav1 @slipy12

9 days later

you need to create appium driver like this:
AppiumDriverLocalService appiumDriver = null;
appiumDriver = AppiumDriverLocalService.buildService(new AppiumServiceBuilder()
.withIPAddress("127.0.0.1")
.usingPort(port)
.withArgument(AndroidServerFlag.BOOTSTRAP_PORT_NUMBER, String.valueOf(bpPort))
.withLogFile(log));

    Field streamsField = null;
    Field streamField = null;

    try {
        streamField = AppiumDriverLocalService.class.getDeclaredField("stream");
        streamField.setAccessible(true);
        streamsField = Class.forName("io.appium.java_client.service.local.ListOutputStream").getDeclaredField("streams");
        streamsField.setAccessible(true);
    } catch (ClassNotFoundException | NoSuchFieldException e) {
        e.printStackTrace();
    }
    try {
        ((ArrayList<OutputStream>) streamsField.get(streamField.get(appiumDriver))).clear(); // remove System.out logging
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }

    appiumDriver.start();

and then you can create android driver using same port like this:

capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, deviceManager.getDeviceName());
capabilities.setCapability(MobileCapabilityType.UDID, deviceManager.getDeviceUdid());
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 60 * 30);
capabilities.setCapability(MobileCapabilityType.NO_RESET, true);
capabilities.setCapability(MobileCapabilityType.FULL_RESET, false);
capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, currentPackageName);
capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, currentActivityName);

    if (apk!= null){
        capabilities.setCapability(MobileCapabilityType.APP, apk.getAbsolutePath());
    }

    URL serverAddress = new URL("http://127.0.0.1:" + port + "/wd/hub");
    androidDriver = new AndroidDriver(serverAddress , capabilities);

In this way, you can create appium + android drivers for each device. I you are running on multiple devices, you can create one for each of them and your tests will run on all devices

1 month later

For anybody reading this who happens to be using npm (node/js/typescript), I've created a module called appium-controller57 that starts and stops appium in the background programmatically (mac or windows) and solves the issues mentioned throughout. Appium logs are stored as well.

8 months later

Hi All,
I’m facing the below exception with Appium-Desktop v1.3.2 (downloaded from appium.io), and trying to connect to appium server but not connecting to server. pls let me know the issue

in the latest version of Appium-Desktop do we need to provide main.js or appium.js file in the commandLineArgument. i tried both but still giving the error.
============================Code i’ve used==================

System.out.println(“Starting appium server”);
/CommandLine cmd = new CommandLine(“cmd”);
cmd.addArgument(“cmd”);
cmd.addArgument("/C");
/
/* cmd.addArgument(“C:\Users\satheeshnukala\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\lib\appium.js”); // commented the appium.js and used main.js file */
CommandLine cmd = new CommandLine(“C:\Program Files\nodejs\node.exe”);
//cmd.addArgument(“C:\Program Files\nodejs\node.exe”);
cmd.addArgument(“C:\Users\satheeshnukala\AppData\Local\Programs\appium-desktop\resources\app\main.js”);
cmd.addArgument("–address");
cmd.addArgument(“127.0.0.1”);
cmd.addArgument("–port");
cmd.addArgument(“4723”);
cmd.addArgument("–no-reset",true);
cmd.addArgument("–full-reset",false);
cmd.addArgument("–log");
cmd.addArgument(“C:\Users\satheeshnukala\workspace\AppiumTest\ConsoleLogs\AppiumConsoleLogs.txt”);

	DefaultExecuteResultHandler handler = new DefaultExecuteResultHandler();
	DefaultExecutor executor = new DefaultExecutor();
	executor.setExitValue(1);
	try {
		executor.execute(cmd, handler);
		Thread.sleep(10000);
	} catch (IOException | InterruptedException e) {
		e.printStackTrace();
	}
	System.out.println("Started appium server");

==================Exception by using main.js===========================
Starting appium server
Started appium server
Step-1
Step-2
Error: Cannot find module 'electron’
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.module.exports.Object.defineProperty.value (C:\Users\satheeshnukala\AppData\Local\Programs\appium-desktop\resources\app\webpack:\external “electron”:1:1)
at webpack_require (C:\Users\satheeshnukala\AppData\Local\Programs\appium-desktop\resources\app\webpack:\webpack\bootstrap dfa496e38cddd9338602:19:1)
at Object. (C:\Users\satheeshnukala\AppData\Local\Programs\appium-desktop\resources\app\webpack:\app\main\main.development.js:1:1)
at webpack_require (C:\Users\satheeshnukala\AppData\Local\Programs\appium-desktop\resources\app\webpack:\webpack\bootstrap dfa496e38cddd9338602:19:1)
at Object. (C:\Users\satheeshnukala\AppData\Local\Programs\appium-desktop\resources\app\main.js:50:19)
at webpack_require (C:\Users\satheeshnukala\AppData\Local\Programs\appium-desktop\resources\app\webpack:\webpack\bootstrap dfa496e38cddd9338602:19:1)
Exception in thread “main” org.openqa.selenium.WebDriverException: Connection refused: connect
Build info: version: ‘3.9.1’, revision: ‘63f7b50’, time: '2018-02-07T22:42:28.403Z’
System info: host: ‘10INLPC0BS59M’, ip: ‘10.216.42.151’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: '1.8.0_144’
Driver info: driver.version: AndroidDriver
at io.appium.java_client.remote.AppiumCommandExecutor.lambda$2(AppiumCommandExecutor.java:141)
at java.util.Optional.orElseGet(Optional.java:267)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:140)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
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.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:142)
at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:38)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:84)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:94)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:77)
at AppiumPackage.AppiumServerJava.startServer(AppiumServerJava.java:62)
at AppiumPackage.AppiumServerJava.main(AppiumServerJava.java:110)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:151)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:91)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:69)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:101)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:138)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:129)
… 12 more

1 month later

appium server can be started using below code, without any hardcoded values:

AppiumServiceBuilder builder = new AppiumServiceBuilder();
builder = new AppiumServiceBuilder();
builder.withIPAddress(“127.0.0.1”);
builder.usingAnyFreePort();
builder.withCapabilities(cap);
builder.withArgument(GeneralServerFlag.SESSION_OVERRIDE);
builder.withArgument(GeneralServerFlag.LOG_LEVEL, “error”);
AppiumDriverLocalService service = AppiumDriverLocalService.buildService(builder);
service.start();
String appiumServiceUrl = service.getUrl().toString();
driver = new AndroidDriver(new URL(appiumServiceUrl), cap);