Appium not running iOS test in terminal.

584 views
Skip to first unread message

Robert-Hein Hooijmans

unread,
Aug 26, 2014, 4:49:58 AM8/26/14
to appium-...@googlegroups.com
Hi guys, I am trying to run my first_test.js on an iOS .app and get this error:

$ node /Users/admin/Desktop/TSAutomations/Tests/first_test.js

/Users/admin/node_modules/wd/node_modules/q/q.js:126 
throw e;
^
Error: [init({"appium-version":"1.2.2","platformName":"iOS","platformVersion":"7.1","deviceName":"iPad Retina","app":"/Users/admin/Desktop/testapp.app"})] The environment you requested was unavailable.
at /Users/admin/node_modules/wd/lib/webdriver.js:124:15
at Request._callback (/Users/admin/node_modules/wd/lib/http-utils.js:84:7)
at Request.self.callback (/Users/admin/node_modules/wd/node_modules/request/request.js:122:22)
at Request.emit (events.js:98:17)
at Request.<anonymous> (/Users/admin/node_modules/wd/node_modules/request/request.js:1019:14)
at Request.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/Users/admin/node_modules/wd/node_modules/request/request.js:970:12)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:943:16
at process._tickCallback (node.js:419:13)

My test looks like this:

"use strict";
var wd = require("wd");
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");

chai.use(chaiAsPromised);
chai.should();
chaiAsPromised.transferPromiseness = wd.transferPromiseness;

var desired = {
"appium-version": "1.2.2",
platformName: "iOS",
platformVersion: "7.1",
deviceName: "iPad Retina",
app: "/Users/admin/Desktop/testapp.app",
};

var browser = wd.promiseChainRemote("0.0.0.0", 4723);

browser.init(desired).then(function() {
return browser
.elementByXPath("//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIAWebView[1]/UIATextField[1]").click()
.fin(function() {
return browser.quit();
});
}).done();

I am running Appium v1.2.2 and Node v0.10.31 in the terminal on a mac.
Can somebody please point out to me what's wrong here?
- Robert-Hein

Isaac Murchie

unread,
Aug 26, 2014, 1:19:55 PM8/26/14
to Robert-Hein Hooijmans, appium-...@googlegroups.com
I would use "127.0.0.1" instead of "0.0.0.0" as the local ip. If that doesn't work, what comes up in the server logs?


--
http://appium.io
---
You received this message because you are subscribed to the Google Groups "Appium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to appium-discus...@googlegroups.com.
Visit this group at http://groups.google.com/group/appium-discuss.
For more options, visit https://groups.google.com/d/optout.

Jeff Fate

unread,
Aug 28, 2014, 10:32:56 AM8/28/14
to appium-...@googlegroups.com, rh.hoo...@gmail.com
I'm having the same or a similar issue.

I've had fine success running my tests using the Appium OS X app, but unable to run when the server is launched from the command line.

I'm passing these parameters to the server when launching it:
--orientation
-U (udid)
--app
--platform-name
--platform-version
--device-name

My test looks like this (I threw in some logs to debug it):

"use strict";

var wd = require("wd");

var desired = {
  platformName: "iOS",
  platformVersion: "7.1.1",
  deviceName: "iPad",
  udid: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  app: "/Users/gvtest/Documents/branches/gvp/mobile/ios/build/Release-iphoneos/TestApp.app"
};

describe("Login", function() {
  var driver;

  beforeEach(function(done) {
    driver = wd.promiseChainRemote("127.0.0.1", 4723);
    driver.init(desired, function(err, sessionId, caps) {
      console.log("err: " + err);
      done();
    });
  }, 60000);

  afterEach(function() {
    driver.quit();
  });

  it("can enter text in user name field", function(done) {
    console.log("waitForElementByXPath");
    driver.waitForElementByXPath('//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIAWebView[1]/UIATextField[1]', 20000, function(err, element) {
      console.log("err: " + err);
      console.log("TouchAction");
      var action = new wd.TouchAction(driver);
      action
        .tap({element: element, x: 10, y: 10})
        .release();
      action
        .perform();
      driver.sleep(5000);
      console.log("sendKeys");
      expect(element
        .sendKeys('TEST').sleep(5000)
        .getValue()).toEqual('TEST');
      console.log("end");
      done();
    });
  }, 60000);
});

I'm running this on a real device, again which I've had no problem doing using the app.

Here's the server output:

info: --> POST /wd/hub/session {"desiredCapabilities":{"platformName":"iOS","platformVersion":"7.1.1","deviceName":"iPad","udid":"xxxxxxxxxxxxxxxxxxxxxxxxxxxx","app":"/Users/gvtest/Documents/branches/gvp/mobile/ios/build/Release-iphoneos/TestApp.app"}}

info: [debug] Using local app from desired caps: /Users/gvtest/Documents/branches/gvp/mobile/ios/build/Release-iphoneos/TestApp.app

info: [debug] Creating new appium session d5d636d7-3cdd-472b-b12c-91da99a7c9a7

info: [debug] Removing any remaining instruments sockets

info: [debug] Cleaned up instruments socket /tmp/instruments_sock

info: [debug] Setting Xcode folder

info: [debug] Setting Xcode version

info: [debug] Setting iOS SDK Version

info: [debug] iOS SDK Version set to 7.1

info: [debug] Detecting automation tracetemplate

info: [debug] Not auto-detecting udid, running on sim

error: Could not parse plist file (as binary) at /Users/gvtest/Documents/branches/gvp/mobile/ios/build/Release-iphoneos/TestApp.app/en.lproj/Localizable.strings

info: Will try to parse the plist file as XML

`parseFileSync()` is deprecated. Use `parseStringSync()` instead.

error: Could not parse plist file (as XML) at /Users/gvtest/Documents/branches/gvp/mobile/ios/build/Release-iphoneos/TestApp.app/en.lproj/Localizable.strings

warn: Could not parse app Localizable.strings

info: [debug] Not setting locale because we're using a real device

info: [debug] Creating instruments

info: [debug] Preparing uiauto bootstrap

info: [debug] Dynamic bootstrap dir:

info: [debug] Dynamic env:

info: [debug] Dynamic bootstrap code:

info: [debug] Dynamic bootstrap path:

info: [debug] Reusing dynamic bootstrap:

info: [debug] Not setting iOS and app preferences since we're on a real device

info: [debug] Starting iOS device log capture via deviceconsole

error: iOS log capture failed: spawn ENOENT

info: [debug] Cleaning up appium session

error: Failed to start an Appium session, err was: Error: spawn ENOENT

info: [debug] Error: spawn ENOENT

    at errnoException (child_process.js:1001:11)

    at Process.ChildProcess._handle.onexit (child_process.js:792:34)

info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: spawn ENOENT)","code":"ENOENT","errno":"ENOENT","syscall":"spawn","origValue":"spawn ENOENT"},"sessionId":null}

info: <-- POST /wd/hub/session 500 982.247 ms - 197 

info: [debug] Not setting device type since we're connected to a device

info: [debug] Getting bundle ID from app

info: [debug] Parsed app Info.plist (as binary)

info: [debug] Creating iDevice object with udid xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

info: [debug] Couldn't find ideviceinstaller, trying built-in at /usr/local/lib/node_modules/appium/build/libimobiledevice-macosx/ideviceinstaller

info: [debug] Checking app install status using: /usr/local/lib/node_modules/appium/build/fruitstrap/fruitstrap isInstalled --id d4688d73d673bf76b2c5089b3d2cb98003ecff09 --bundle com.testapp.mobile.enterprise

info: --> POST /wd/hub/session/elements {"using":"xpath","value":"//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIAWebView[1]/UIATextField[1]"}

info: <-- POST /wd/hub/session/elements 404 2.592 ms - 40 

info: --> POST /wd/hub/session/touch/perform [{"action":"tap","options":{"x":10,"y":10}},{"action":"release","options":{}}]

info: <-- POST /wd/hub/session/touch/perform 404 0.791 ms - 40 

info: [debug] App is installed.

info: [debug] fullReset not requested. No need to install.

info: [debug] Starting command proxy.

info: [debug] Instruments socket server started at /tmp/instruments_sock

info: [debug] Starting instruments

info: [debug] Instruments is at: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments

info: Launching instruments

info: [debug] Attempting to run app on real device with UDID xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

info: [debug] Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate -D /tmp/appium-instruments/instrumentscli0.trace -w d4688d73d673bf76b2c5089b3d2cb98003ecff09 /Users/gvtest/Documents/branches/gvp/mobile/ios/build/Release-iphoneos/TestApp.app -e UIASCRIPT /Users/gvtest/Library/Application Support/appium/bootstrap/bootstrap-5b9dd60914bc1b23.js -e UIARESULTSPATH /tmp/appium-instruments

info: [debug] And extra without-delay env: {}

info: [debug] And launch timeouts (in ms): {"global":90000}

info: Instruments is ready to receive commands

info: [debug] Instruments launched. Starting poll loop for new commands.

info: [debug] Setting bootstrap config keys/values

info: [debug] Pushing command to appium work queue: "target = $.target();\nau = $;\n$.isVerbose = true;\nautoAcceptAlerts = false;\n"

info: [debug] Sending command to instruments: target = $.target();

au = $;

$.isVerbose = true;

autoAcceptAlerts = false;


info: [debug] Socket data received (2 bytes)

info: [debug] Socket data being routed.

info: [debug] Sending command to instruments: target = $.target();

au = $;

$.isVerbose = true;

autoAcceptAlerts = false;


info: [debug] [INST] 2014-08-28 14:22:16 +0000 Debug: evaluation finished

       

info: [debug] [INST] 2014-08-28 14:22:16 +0000 Debug: responding with:

       

info: [debug] [INST] 2014-08-28 14:22:16 +0000 Debug: Running system command #1: /usr/local/Cellar/node/0.10.31/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":false}...

       

info: [debug] Socket data received (28 bytes)

info: [debug] Socket data being routed.

info: [debug] Got result from instruments: {"status":0,"value":false}

info: [debug] Setting initial orientation to LANDSCAPE

info: [debug] Pushing command to appium work queue: "au.setScreenOrientation('LANDSCAPE')"

info: [debug] Sending command to instruments: au.setScreenOrientation('LANDSCAPE')

info: [debug] Sending command to instruments: au.setScreenOrientation('LANDSCAPE')

info: [debug] [INST] 2014-08-28 14:22:17 +0000 Debug: Got new command 1 from instruments: au.setScreenOrientation('LANDSCAPE')

       

info: [debug] [INST] 2014-08-28 14:22:17 +0000 Debug: evaluating au.setScreenOrientation('LANDSCAPE')

       

info: [debug] [INST] 2014-08-28 14:22:17 +0000 Debug: target.setDeviceOrientation("3")

       

info: [debug] [INST] 2014-08-28 14:22:18 +0000 Debug: evaluation finished

       

info: [debug] [INST] 2014-08-28 14:22:18 +0000 Debug: responding with:

       

info: [debug] [INST] 2014-08-28 14:22:18 +0000 Debug: Running system command #2: /usr/local/Cellar/node/0.10.31/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":"LANDSCAPE"}...

       

info: [debug] Socket data received (34 bytes)

info: [debug] Socket data being routed.

info: [debug] Got result from instruments: {"status":0,"value":"LANDSCAPE"}

info: --> DELETE /wd/hub/session {}

info: [debug] Trying to stop appium but there's no session, doing nothing

info: [debug] Responding to client with error: {"status":1,"value":{"message":"undefined status object"},"sessionId":null}

info: <-- DELETE /wd/hub/session 500 2.198 ms - 75 

The test output:

$ jasmine-node demo-spec.js 

err: Error: [init({"platformName":"iOS","platformVersion":"7.1.1","deviceName":"iPad","udid":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","app":"/Users/gvtest/Documents/branches/gvp/mobile/ios/build/Release-iphoneos/TestApp.app"})] The environment you requested was unavailable.

waitForElementByXPath

err: Error: [waitForElementByXPath("//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIAWebView[1]/UIATextField[1]",20000)] [elements("xpath","//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIAWebView[1]/UIATextField[1]")] Error response status: 6, 

TouchAction

sendKeys

F


Failures:


  1) Login can enter text in user name field

   Message:

     timeout: timed out after 60000 msec waiting for spec to complete

   Stacktrace:

     undefined


Finished in 67.322 seconds

1 test, 1 assertion, 1 failure, 0 skipped

Isaac Murchie

unread,
Aug 28, 2014, 12:29:39 PM8/28/14
to Jeff Fate, appium-...@googlegroups.com, Robert-Hein Hooijmans
Have you run reset.sh? There is a new dependency, "deviceconsole", which needs to be built. With it, log capture in iOS ought to be much more reliable.

Jeff Fate

unread,
Aug 28, 2014, 2:50:45 PM8/28/14
to appium-...@googlegroups.com, fat...@gmail.com, rh.hoo...@gmail.com
I haven't. I installed it via npm so don't believe I have that file...?

Isaac Murchie

unread,
Aug 28, 2014, 4:32:51 PM8/28/14
to Jeff Fate, appium-...@googlegroups.com, Robert-Hein Hooijmans
Hmm. The file ought to be built in the publish process. I will look into it.

In the meantime, you can go into build/deviceconsole and run `make`.
Reply all
Reply to author
Forward
0 new messages