Basics: Getting started with Appium for iOS and Android devices

Hello,

I have created a documentation which will cover the basic steps to start automation testing with Appium. Thought it might be useful for someone if I share.

Tags: Basic Steps, Beginners Guide, Help, Documentation, Mobile Automation.

Please find the following link for the PDF format of below document :

Below link contains the modified document with images:

5 Likes

Can you just post it as pdf?

Let me a little bit correct you. It is not necessary to define platform for Android/IOSDriver
e.g.

Capabilities.setCapability(“platformName”,“Android”)

Platform is set up automatically inside constructor of each driver.

Hi @aluedeke , I cant find any option to upload pdf (only jpg, jpeg, png, gif, txt, log).

Upload the file (scribd.com, docdroid.net, pdfcast.org, etc.) and share the link

@Telmo_Cardoso: Thanks man !

@aluedeke: Please find below link.

1 Like

Very nice and very helpful for starter.
Thank you.

Hi Prithivi,

That is very helpful. I am currently working on iOS native app test automation. I want to run the test on real device and I have the .ipa file (signed with valid developer provisioning profile). But I am not able to launch the app successfully using the code:

public class iosTest {
public AppiumDriver driver = null;

public static void main(String[] args) throws MalformedURLException,
		InterruptedException {

	iosTest testcases = new iosTest();

	// set up appium and launch app
	testcases.setUp();


	testcases.checkApp();


}

public void setUp() {

	try {

		System.out.println("Launching App");

		DesiredCapabilities capabilities = new DesiredCapabilities();
		capabilities.setCapability("deviceName", "iPhone");
		capabilities.setCapability("platformName", "iOS"); 
		capabilities.setCapability("udid", "7f29f386e640b1f798fcde4a17a533cad19214ae");
		capabilities.setCapability("bundleid", "com.nbcuni.oxygen.tve");
		capabilities.setCapability("ipa", "/Users/Automation1/Documents/appFiles/Oxygen_AdhocEnterprise_3.0.0_154.ipa");
		driver = new AppiumDriver( new URL("http://127.0.0.1:4723/wd/hub"), capabilities); 
		 

		System.out.println("App launched");
		
		Thread.sleep(5000);

	} catch (Exception e) {
		System.out.println("App launch fail");
	
	}
}


public void checkApp() throws InterruptedException {

	try {

		driver.wait();
	
		Thread.sleep(5000);

	} catch (AssertionError ex) {
		System.out.println(ex);
	}

}

}

Is it possible to automate using .ipa file on real device

@neharm27: We should be able to automate using .ipa file if its correctly-signed for real devices. It was metioned in Appium documentation as well.
Try giving the .ipa file path and UDID in iOS settings in Appium itself and post the log if failed.

Hi Prithivi,

I see the Instuments crashed on startup error -
Appium logs -

info: Welcome to Appium v1.3.3 (REV 34e21b01b87d4e3959e1c97c0a8d0b1a610bdc78)

info: Appium REST http interface listener started on 127.0.0.1:4723
info: [debug] Non-default server args: {“app”:"/Users/Automation1/Documents/appFiles/Oxygen_AdhocEnterprise_3.0.0_154.ipa",“udid”:“c29653d8fd774a54ca72f993c9af95690fbe896e”,“address”:“127.0.0.1”,“deviceName”:“iPhone 5s”,“showSimulatorLog”:true,“defaultCommandTimeout”:7200}
warn: Deprecated server args: {"–show-sim-log":“use instead: --show-ios-log”}
info: Console LogLevel: debug

info: --> GET /wd/hub/status {}

info: [debug] Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.3.3”,“revision”:“34e21b01b87d4e3959e1c97c0a8d0b1a610bdc78”}}}

info: <-- GET /wd/hub/status 200 7.197 ms - 104 {“status”:0,“value”:{“build”:{“version”:“1.3.3”,“revision”:“34e21b01b87d4e3959e1c97c0a8d0b1a610bdc78”}}}

info: --> GET /wd/hub/status {}

info: [debug] Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.3.3”,“revision”:“34e21b01b87d4e3959e1c97c0a8d0b1a610bdc78”}}}

info: <-- GET /wd/hub/status 200 1.981 ms - 104 {“status”:0,“value”:{“build”:{“version”:“1.3.3”,“revision”:“34e21b01b87d4e3959e1c97c0a8d0b1a610bdc78”}}}

info: --> POST /wd/hub/session {“desiredCapabilities”:{“bundleid”:“com.nbcuni.oxygen.tve”,“ipa”:“Oxygen_AdhocEnterprise_3.0.0_154.ipa”,“platformName”:“iOS”,“deviceName”:“iPhone”,“udid”:“c29653d8fd774a54ca72f993c9af95690fbe896e”}}

info: Client User-Agent string: Apache-HttpClient/4.3.4 (java 1.5)

info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : bundleid, ipa
info: [debug] Using local .ipa from command line: /Users/Automation1/Documents/appFiles/Oxygen_AdhocEnterprise_3.0.0_154.ipa
info: [debug] Copying local zip to tmp dir

info: [debug] /Users/Automation1/Documents/appFiles/Oxygen_AdhocEnterprise_3.0.0_154.ipa copied to /var/folders/20/tllz4ybx35j50gjlgh792_yw0000gn/T/1141123-1091-64ath0/appium-app.zip

info: [debug] Unzipping /var/folders/20/tllz4ybx35j50gjlgh792_yw0000gn/T/1141123-1091-64ath0/appium-app.zip

info: [debug] Testing zip archive: /var/folders/20/tllz4ybx35j50gjlgh792_yw0000gn/T/1141123-1091-64ath0/appium-app.zip

info: [debug] Zip archive tested clean

info: [debug] Unzip successful

info: [debug] Using locally extracted app: /var/folders/20/tllz4ybx35j50gjlgh792_yw0000gn/T/1141123-1091-64ath0/Payload/Oxygen Now.app

info: [debug] Creating new appium session 4e016ab7-c566-4dca-84fb-b2feff6678d6
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] Getting sdk version from xcrun with a timeout

info: [debug] iOS SDK Version set to 8.1

info: [debug] Not checking whether simulator is available since we’re on a real device
info: [debug] Detecting automation tracetemplate

info: [debug] Not auto-detecting udid, running on sim
info: [debug] Could not parse plist file (as binary) at /var/folders/20/tllz4ybx35j50gjlgh792_yw0000gn/T/1141123-1091-64ath0/Payload/Oxygen Now.app/en.lproj/Localizable.strings
info: Will try to parse the plist file as XML
info: [debug] Could not parse plist file (as XML) at /var/folders/20/tllz4ybx35j50gjlgh792_yw0000gn/T/1141123-1091-64ath0/Payload/Oxygen Now.app/en.lproj/Localizable.strings
warn: Could not parse app Localizable.strings; assuming it doesn’t exist
info: [debug] Getting bundle ID from app
info: [debug] Could not parse plist file (as binary) at /var/folders/20/tllz4ybx35j50gjlgh792_yw0000gn/T/1141123-1091-64ath0/Payload/Oxygen Now.app/Info.plist
info: Will try to parse the plist file as XML

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

info: [debug] Parsed app Info.plist (as XML)
info: [debug] Creating instruments
info: On some xcode 6 platforms, instruments-without-delay does not work. If you experience this, you will need to re-run appium with the --native-instruments-lib flag
info: [debug] Preparing uiauto bootstrap
info: [debug] Dynamic bootstrap dir: /Users/Automation1/Library/Application Support/appium/bootstrap

parseStringSync() is deprecated. Use parse() instead.

info: [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,“sendKeyStrategy”:“grouped”}
info: [debug] Dynamic bootstrap code: // This file is automatically generated. Do not manually modify!
…
info: [debug] Dynamic bootstrap path: /Users/Automation1/Library/Application Support/appium/bootstrap/bootstrap-0943baae6b1d6f5b.js
info: [debug] Reusing dynamic bootstrap: /Users/Automation1/Library/Application Support/appium/bootstrap/bootstrap-0943baae6b1d6f5b.js
info: [debug] Getting device string from opts: {“forceIphone”:false,“forceIpad”:false,“xcodeVersion”:“6.1”,“iOSSDKVersion”:“8.1”,“deviceName”:“iPhone”,“platformVersion”:null}
info: [debug] fixDevice is on
info: [debug] Final device string is: ‘iPhone (8.1 Simulator)’
info: [debug] Not setting device type since we’re on a real device
info: [debug] Checking whether we need to set app preferences
info: [debug] Not setting iOS and app preferences since we’re on a real device
info: [debug] Running ios sim reset flow
info: [debug] Killing the simulator process
info: [debug] Killall iOS Simulator
info: [debug] Killing any other simulator daemons

info: [debug] On a real device; cannot clean device state
info: [debug] Not setting locale because we’re using a real device
info: [debug] No iOS / app preferences to set

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

info: [debug] Not pre-launching simulator

info: [debug] Creating iDevice object with udid c29653d8fd774a54ca72f993c9af95690fbe896e
info: [debug] Checking app install status using: /Applications/Appium.app/Contents/Resources/node_modules/appium/build/fruitstrap/fruitstrap isInstalled --id c29653d8fd774a54ca72f993c9af95690fbe896e --bundle com.nbcuni.oxygen

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 c29653d8fd774a54ca72f993c9af95690fbe896e
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 c29653d8fd774a54ca72f993c9af95690fbe896e com.nbcuni.oxygen -e UIASCRIPT “/Users/Automation1/Library/Application Support/appium/bootstrap/bootstrap-0943baae6b1d6f5b.js” -e UIARESULTSPATH /tmp/appium-instruments
info: [debug] And extra without-delay env: {}
info: [debug] And launch timeouts (in ms): {“global”:90000}

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 iOS Simulator

info: [IOS_SYSLOG_ROW ] Dec 23 12:36:11 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22

info: [IOS_SYSLOG_ROW ] Dec 23 12:36:11 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument

info: [IOS_SYSLOG_ROW ] Dec 23 12:36:11 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22
info: [IOS_SYSLOG_ROW ] Dec 23 12:36:11 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument
info: [IOS_SYSLOG_ROW ] Dec 23 12:36:12 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22

info: [IOS_SYSLOG_ROW ] Dec 23 12:36:12 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument
info: [IOS_SYSLOG_ROW ] Dec 23 12:36:12 Nehas-iPhone DTMobileIS[6062] : Could not create service named com.apple.instruments.server.services.processcontrol.posixspawn
info: [IOS_SYSLOG_ROW ] Dec 23 12:36:12 Nehas-iPhone DTMobileIS[6062] : Could not create service named com.apple.instruments.server.services.launchdaemon

info: [IOS_SYSLOG_ROW ] Dec 23 12:36:12 Nehas-iPhone notification_proxy[6060] : 0x10040c000 -[MNPLockdownConnection receiveMessage]: lockdown_receive_message error!
info: [IOS_SYSLOG_ROW ] Dec 23 12:36:12 Nehas-iPhone notification_proxy[6060] : 0x10040c000 -[MNPLockdownConnection receiveMessage]: lockdown_receive_message error!
info: [IOS_SYSLOG_ROW ] Dec 23 12:36:17 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22
info: [IOS_SYSLOG_ROW ] Dec 23 12:36:17 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument
info: [IOS_SYSLOG_ROW ] Dec 23 12:36:17 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22
info: [IOS_SYSLOG_ROW ] Dec 23 12:36:17 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument

info: [IOS_SYSLOG_ROW ] Dec 23 12:36:17 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22
info: [IOS_SYSLOG_ROW ] Dec 23 12:36:17 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument
info: [IOS_SYSLOG_ROW ] Dec 23 12:36:18 Nehas-iPhone DTMobileIS[6062] : Could not create service named com.apple.instruments.server.services.processcontrol.posixspawn

info: [IOS_SYSLOG_ROW ] Dec 23 12:36:18 Nehas-iPhone DTMobileIS[6062] : Could not create service named com.apple.instruments.server.services.launchdaemon
info: [IOS_SYSLOG_ROW ] Dec 23 12:36:18 Nehas-iPhone notification_proxy[6060] : 0x100494000 -[MNPLockdownConnection receiveMessage]: lockdown_receive_message error!
info: [IOS_SYSLOG_ROW ] Dec 23 12:36:18 Nehas-iPhone notification_proxy[6060] : 0x100494000 -[MNPLockdownConnection receiveMessage]: lockdown_receive_message error!
info: [IOS_SYSLOG_ROW ] Dec 23 12:36:23 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22

info: [IOS_SYSLOG_ROW ] Dec 23 12:36:23 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument
info: [IOS_SYSLOG_ROW ] Dec 23 12:36:23 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22
info: [IOS_SYSLOG_ROW ] Dec 23 12:36:23 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument
info: [IOS_SYSLOG_ROW ] Dec 23 12:36:23 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22
info: [IOS_SYSLOG_ROW ] Dec 23 12:36:23 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument

info: [IOS_SYSLOG_ROW ] Dec 23 12:36:24 Nehas-iPhone DTMobileIS[6062] : Could not create service named com.apple.instruments.server.services.launchdaemon
info: [IOS_SYSLOG_ROW ] Dec 23 12:36:24 Nehas-iPhone DTMobileIS[6062] : Could not create service named com.apple.instruments.server.services.processcontrol.posixspawn
info: [IOS_SYSLOG_ROW ] Dec 23 12:36:24 Nehas-iPhone notification_proxy[6060] : 0x100384000 -[MNPLockdownConnection receiveMessage]: lockdown_receive_message error!
info: [IOS_SYSLOG_ROW ] Dec 23 12:36:24 Nehas-iPhone notification_proxy[6060] : 0x100384000 -[MNPLockdownConnection receiveMessage]: lockdown_receive_message error!

info: [IOS_SYSLOG_ROW ] Dec 23 12:36:39 Nehas-iPhone locationd[4960] : Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:28 Nehas-iPhone locationd[4960] : Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:37 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:37 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument

info: [IOS_SYSLOG_ROW ] Dec 23 12:38:38 Nehas-iPhone syslog_relay[6063] : syslog_relay found the ASL prompt. Starting…
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:41 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:38 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:41 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:39 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:41 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:39 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:39 Nehas-iPhone mobile_installation_proxy[6075] : 0x10052c000 handle_connection: Could not receive request from host.
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:41 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:40 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:41 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:40 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:41 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22

info: [IOS_SYSLOG_ROW ] Dec 23 12:38:40 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:40 Nehas-iPhone DTMobileIS[6062] : Could not create service named com.apple.instruments.server.services.launchdaemon
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:40 Nehas-iPhone DTMobileIS[6062] : Could not create service named com.apple.instruments.server.services.processcontrol.posixspawn
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:40 Nehas-iPhone notification_proxy[6060] : 0x10040c000 -[MNPLockdownConnection receiveMessage]: lockdown_receive_message error!
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:40 Nehas-iPhone notification_proxy[6060] : 0x10040c000 -[MNPLockdownConnection receiveMessage]: lockdown_receive_message error!

info: Launching instruments

info: [debug] Attempting to run app on real device with UDID c29653d8fd774a54ca72f993c9af95690fbe896e
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 c29653d8fd774a54ca72f993c9af95690fbe896e com.nbcuni.oxygen -e UIASCRIPT “/Users/Automation1/Library/Application Support/appium/bootstrap/bootstrap-0943baae6b1d6f5b.js” -e UIARESULTSPATH /tmp/appium-instruments
info: [debug] And extra without-delay env: {}

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

info: [IOS_SYSLOG_ROW ] Dec 23 12:38:46 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22

info: [IOS_SYSLOG_ROW ] Dec 23 12:38:46 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument

info: [IOS_SYSLOG_ROW ] Dec 23 12:38:46 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22

info: [IOS_SYSLOG_ROW ] Dec 23 12:38:46 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument

info: [IOS_SYSLOG_ROW ] Dec 23 12:38:46 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22

info: [IOS_SYSLOG_ROW ] Dec 23 12:38:46 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument

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 #2
info: [debug] Killall iOS Simulator
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:46 Nehas-iPhone DTMobileIS[6062] : Could not create service named com.apple.instruments.server.services.launchdaemon
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:46 Nehas-iPhone DTMobileIS[6062] : Could not create service named com.apple.instruments.server.services.processcontrol.posixspawn
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:46 Nehas-iPhone notification_proxy[6060] : 0x10040c000 -[MNPLockdownConnection receiveMessage]: lockdown_receive_message error!
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:46 Nehas-iPhone notification_proxy[6060] : 0x10040c000 -[MNPLockdownConnection receiveMessage]: lockdown_receive_message error!

info: Launching instruments

info: [debug] Attempting to run app on real device with UDID c29653d8fd774a54ca72f993c9af95690fbe896e
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 c29653d8fd774a54ca72f993c9af95690fbe896e com.nbcuni.oxygen -e UIASCRIPT “/Users/Automation1/Library/Application Support/appium/bootstrap/bootstrap-0943baae6b1d6f5b.js” -e UIARESULTSPATH /tmp/appium-instruments
info: [debug] And extra without-delay env: {}

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

info: [IOS_SYSLOG_ROW ] Dec 23 12:38:51 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22

info: [IOS_SYSLOG_ROW ] Dec 23 12:38:51 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument

info: [IOS_SYSLOG_ROW ] Dec 23 12:38:51 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22

info: [IOS_SYSLOG_ROW ] Dec 23 12:38:51 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument

info: [IOS_SYSLOG_ROW ] Dec 23 12:38:52 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:52 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument

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 #3
info: [debug] Killall iOS Simulator
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:52 Nehas-iPhone DTMobileIS[6062] : Could not create service named com.apple.instruments.server.services.processcontrol.posixspawn
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:52 Nehas-iPhone DTMobileIS[6062] : Could not create service named com.apple.instruments.server.services.launchdaemon
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:52 Nehas-iPhone notification_proxy[6060] : 0x10040c000 -[MNPLockdownConnection receiveMessage]: lockdown_receive_message error!
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:52 Nehas-iPhone notification_proxy[6060] : 0x10040c000 -[MNPLockdownConnection receiveMessage]: lockdown_receive_message error!

info: Launching instruments

info: [debug] Attempting to run app on real device with UDID c29653d8fd774a54ca72f993c9af95690fbe896e
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 c29653d8fd774a54ca72f993c9af95690fbe896e com.nbcuni.oxygen -e UIASCRIPT “/Users/Automation1/Library/Application Support/appium/bootstrap/bootstrap-0943baae6b1d6f5b.js” -e UIARESULTSPATH /tmp/appium-instruments
info: [debug] And extra without-delay env: {}
info: [debug] And launch timeouts (in ms): {“global”:90000}

info: [IOS_SYSLOG_ROW ] Dec 23 12:38:57 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22

info: [IOS_SYSLOG_ROW ] Dec 23 12:38:57 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument

info: [IOS_SYSLOG_ROW ] Dec 23 12:38:57 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22

info: [IOS_SYSLOG_ROW ] Dec 23 12:38:57 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument

info: [IOS_SYSLOG_ROW ] Dec 23 12:38:57 Nehas-iPhone kernel[0] : flow_divert_token_set (0): Failed to get the key unit from the token: 22

info: [IOS_SYSLOG_ROW ] Dec 23 12:38:57 Nehas-iPhone lockdownd[63] : Could not set socket option SO_OPPORTUNISTIC: Invalid argument

info: [debug] [INSTSERVER] Instruments exited with code 253

info: [debug] Killall instruments

error: Failed to start an Appium session, err was: Error: Instruments crashed on startup

info: [debug] Instruments crashed on startup
info: [debug] We exceeded the number of retries allowed for instruments to successfully start; failing launch
info: [debug] Stopping iOS log capture
info: [debug] Running ios sim reset flow
info: [debug] Killing the simulator process
info: [debug] Killall iOS Simulator
info: [debug] Killing any other simulator daemons
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:57 Nehas-iPhone DTMobileIS[6062] : Could not create service named com.apple.instruments.server.services.processcontrol.posixspawn
info: [IOS_SYSLOG_ROW ] Dec 23 12:38:57 Nehas-iPhone DTMobileIS[6062] : Could not create service named com.apple.instruments.server.services.launchdaemon
info: [debug] On a real device; cannot clean device state
info: [debug] Cleaning up appium session
info: [debug] Error: Instruments crashed on startup
at Instruments.onInstrumentsExit (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:387:31)
at null. (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:308:12)
at ChildProcess.emit (events.js:98:17)
at Process.ChildProcess._handle.onexit (child_process.js:810:12)
info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Instruments crashed on startup)”,“origValue”:“Instruments crashed on startup”},“sessionId”:null}
info: <-- POST /wd/hub/session 500 21435.328 ms - 182

Are you passing these “bundleid, ipa” values from Appium’s iOS settings or from your code ?
If through code, remove them and put the settings in Appium itself.
And as far as i know, bundleid will be taken automatically by Appium.

Hi, Prithivi Can you please tell me how to do retry if screenshot is not taken.

@Chirag_Khimani : Take the screenshot again in catch() block. If not working use another try, catch inside your catch() block. Maximum 3 or 4 tries, if you are still getting error then something else is wrong.

try{
	File screenShot = appiumDriver.getScreenshotAs(OutputType.FILE);
	FileUtils.copyFile(screenShot, new File(currentSessionScreenShotpath + fileName+ fileFormat));
}
	catch (Exception e) {
		File screenShot = appiumDriver.getScreenshotAs(OutputType.FILE);
		FileUtils.copyFile(screenShot, new File(currentSessionScreenShotpath + fileName+ fileFormat));
}

The Document is very usefull.
Thaks a lot

Hi

@Prithivi

I was on vacation and started looking at this actively now again.

Hope you are doing great!

The Appium settings are:

iOS settings – Added App path – path to .ipa file, (tried w/ and w/o bundle id)

But it keeps giving me ‘fruitstrap quit unexpectedly.’ Error

If possible can you point out where I might be going wrong?

I am using:
Xcode 6.1
Mac Mini – OS X Yosemite
Appium 1.3.4

Actual code to initialize the mobile driver and launch the app is:

import io.appium.java_client.AppiumDriver;

import java.net.URL;

public class iosTest {

public AppiumDriver driver = null;

public static void main(String[] args) throws MalformedURLException, InterruptedException {

iosTest testcases = new iosTest();

// set up appium and launch app

testcases.setUp();

testcases.checkApp();

}

public void setUp() {

try {

System.out.println(“Launching App”);

DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability(“deviceName”, “iPhone 5″);

capabilities.setCapability(“platformName”,”iOS”);

//capabilities.setCapability(“udid”, “7f29f386e640b1f798fcde4a17a533cad19214ae”);

//Neha’s iphone

//capabilities.setCapability(“udid”, “c29653d8fd774a54ca72f993c9af95690fbe896e”);

//iPhone QA 00021

capabilities.setCapability(“udid”, “324ab330617695b424fd62858a45ef5646628330″);

driver = new AppiumDriver( new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);

System.out.println(“App launched”);

Thread.sleep(5000);

} catch (Exception e) {

System.out.println(“App launch fail”);

}

}

public void checkApp() throws InterruptedException {

try {

driver.findElementByName(“now”);

Thread.sleep(5000);

} catch (AssertionError ex) {

System.out.println(ex);

}

}

}

Thanks,
Neha R. Malviya

Thanks a lot @prithivi,

     I tried that and its successfully takes screenshot in specified folder if appium fails to take screenshot. But when appium fails to take screenshot it throws exception "Time out waiting for screenshot file". So I got screenshot successfully but exception is still getting. Is there any way to ignore this exception?

Thanks
Chirag

Hi everyone
I am new to the mobile automation(Android and IOS) need to work on windows platform can anybody please help me with the steps to start the automation for webview, native and hybrid.
Please do the needful.
Thanks in advance

Hi @Prithivi,

Can you Please help me to identify elements/objects in Android. Please have a look at following link.

I followed your document and successfully able to setup and run test on Android device. Thanks for your effort.

Regards,
Jagadeesh
Email: [email protected]

Hi Prithvi,

I am beginner in Mobile Automation.
Please provide documentation which will cover the basic steps to start automation testing with Appium on Windows for iOS and Android devices.

Thanks & Regards,
Jalpesh

I have created a step by step tutorial and Youtube video on how to correctly sign the App to an .ipa file for real iOS devices.

Hope it helps.

1 Like