@ 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
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.
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
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
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
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
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
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
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.