1

appium : 1.4.13

xcode : 7.1

ios: 9.1

desired_caps = dict()
            desired_caps['platformName'] = 'iOS'
            desired_caps['platformVersion'] = '9.1'
            desired_caps['deviceName'] = 'iPhone 6'
            desired_caps['app'] = os.path.abspath('/Users/Test.app')
            self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

It always lauches simulator even though real device is attached.

I am trying to run on device.

And simulator keeps lauching and shutting down.

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 iPhone 6 (9.1) [
info: On xcode 7.0, instruments-without-delay does not work, skippinginstruments-without-delay
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.xrplugin/Contents/Resources/Automation.tracetemplate -D /tmp/appium-instruments/instrumentscli0.trace -w "iPhone 6 (9.1) [" /Users/Test.app -e UIASCRIPT "/Users/Library/Application Support/appium/bootstrap/bootstrap-bf740a9394e481ef.js" -e UIARESULTSPATH /tmp/appium-instruments
info: [debug] And launch timeouts (in ms): {"global":90000}
info: [debug] [INST] Waiting for device to boot...
info: [debug] [INST STDERR] 2015-10-21 13:29:31.895 instruments[3192:50268] WebKit Threading Violation - initial use of WebKit from a secondary thread.
info: [debug] [INST STDERR] 2015-10-21 13:29:53.976 instruments[3192:50261] Attempting to change event horizon while disengage
info: [debug] [INST STDERR] 2015-10-21 13:29:53.976 instruments[3192:51306] Attempting to change event horizon while disengage
info: [debug] [INST STDERR] Instruments Trace Error : Target failed to run: The operation couldn’t be completed. (FBSOpenApplicationErrorDomain error 1.) : Failed to launch process with bundle identifier 'com.apsalar.sdkBatchTest2'
info: [debug] [INSTSERVER] Instruments exited with code 253
info: [debug] Killall instruments
info: [debug] Instruments crashed on startup
info: [debug] Attempting to retry launching instruments, this is retry #1
info: [debug] Killall Simulator
info: Launching instruments
info: [debug] Attempting to run app on iPhone 6 (9.1) [
info: On xcode 7.0, instruments-without-delay does not work, skippinginstruments-without-delay
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.xrplugin/Contents/Resources/Automation.tracetemplate -D /tmp/appium-instruments/instrumentscli0.trace -w "iPhone 6 (9.1) [" /Users/Test.app -e UIASCRIPT "/Users/Library/Application Support/appium/bootstrap/bootstrap-bf740a9394e481ef.js" -e UIARESULTSPATH /tmp/appium-instruments
info: [debug] And launch timeouts (in ms): {"global":90000}
info: [debug] [INST STDERR] 2015-10-21 13:30:00.033 instruments[3298:51578] **WebKit Threading Violation - initial use of WebKit from a secondary thread.**
info: [debug] [INST] Waiting for device to boot...
info: [debug] [INST STDERR] 2015-10-21 13:30:07.851 instruments[3298:51576] Attempting to change event horizon while disengage
info: [debug] [INST STDERR] 2015-10-21 13:30:07.851 instruments[3298:51577] Attempting to change event horizon while disengage
info: [debug] [INST STDERR] Instruments Trace Error : Target failed to run: The operation couldn’t be completed. (FBSOpenApplicationErrorDomain error 1.) : Failed to launch process with bundle identifier 'com.apsalar.sdkBatchTest2'
info: [debug] [INSTSERVER] Instruments exited with code 253
info: [debug] Killall instruments
user2661518
  • 2,677
  • 9
  • 42
  • 79
  • 1
    try to pass udid in deviceName – Gaurav Oct 21 '15 at 21:05
  • `info: [debug] Getting device string from opts: {"forceIphone":false,"forceIpad":false,"xcodeVersion":"7.1","iOSSDKVersion":"9.1","deviceName":"09d905a109245efebd23ab741c0900e83769b3ae","platformVersion":"9.1"} info: [debug] fixDevice is on info: [debug] Final device string is: '09d905a109245efebd23ab741c0900e83769b3ae (9.1)' error: Could not find a device to launch. You requested '09d905a109245efebd23ab741c0900e83769b3ae (9.1)', but the available devices were: ["iPad 2 (8.1) [97826D6B-9376-4E1A-BFDB-0EB4A00480ED]","iPad 2 (9.1) [C05B61A8-BC0B-4FAB-9B67-DBFF994F19FD]","iPad Air (8.1) .....` – user2661518 Oct 21 '15 at 21:07
  • I tried that as well I get 'could not find device' error – user2661518 Oct 21 '15 at 21:10
  • no change deviceName to "udid" and try again – Gaurav Oct 21 '15 at 21:31
  • adding udid along with device name worked – user2661518 Oct 21 '15 at 21:34
  • cool. i just posted my answer as well so that helpful to other people as well. – Gaurav Oct 21 '15 at 21:38

3 Answers3

0

Adding udid worked !!

desired_caps = dict()
            desired_caps['platformName'] = 'iOS'
            desired_caps['platformVersion'] = '9.1'
            desired_caps['deviceName'] = 'iPhone 6'
            desired_caps['udid'] = '09d905a109245efebd23ab741c0900e83769b3ae'
            desired_caps['app'] = os.path.abspath('/Users/Test.app')
            self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
user2661518
  • 2,677
  • 9
  • 42
  • 79
0

Add "udid" capability and enter your device udid there.

capabilities.setCapability("deviceName", "phoneUDID");
Gaurav
  • 1,332
  • 11
  • 22
0

1) First of All: Enable UIAutomation of iOS Device Setting > Developer > Enable UI Automation

2) Start the Appium instance with real device UDID

like: node . -p 4725 -bp 2553 -U ""

3) and Add Capability in you test code as follows:

    File rootDir = new File(System.getProperty("user.dir"));
    File appDir = new File(rootDir, "folder");
    File app = new File(appDir, AppName);

    DesiredCapabilities capabilities = new DesiredCapabilities();

    /*Capabilities for Simulator*/
//  capabilities.setCapability("deviceName", "iPhone 6");
    /*Capabilities for Simulator*/

    /*Capabilities for Device*/
    capabilities.setCapability("deviceName", "Wasim~iPhone");
    /*Capabilities for Device*/

    capabilities.setCapability("platformVersion", "9.1");
    capabilities.setCapability("platformName", "iOS");
    capabilities.setCapability("autoAcceptAlerts",true); //this auto accepts the Notification alert

    capabilities.setCapability("platformVersion", "9.1");
    capabilities.setCapability("noReset",true);

    if (isfirstTimeStart) {

        capabilities.setCapability("app", app.getAbsolutePath());

    }else {

        capabilities.setCapability("bundleId", bundleId);

    }

    driver = new AppiumDriver(new URL("http://127.0.0.1:4725/wd/hub"), capabilities);

So DeviceName is important to run on Device and also UDID when running appium server instance.

Wasim
  • 921
  • 12
  • 14