Can Appium access and operate iphone's settings page

Hi All,
I have a automation requirement that I need to get some value from settings in iOS(iphone&ipad), I am a new Appium guy, anybody can tell me how to do ?

@Andy_Zhao: Please watch my video to open setting page in ios devices.

Thank you very much. I followed video, but my code still not works fine, I will check it continue. thanks again

I have tried it on real device follow the video, and met a issue as below.

Code:
import java.net.URL;
import io.appium.java_client.AppiumDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;

public class Main {
public static void main(String[] args) throws Exception {
AppiumDriver driver;
DesiredCapabilities ca = new DesiredCapabilities();
ca.setCapability(“platformName”, “iOS”);
ca.setCapability(“deviceName”, “iPhone4”);
ca.setCapability(“platformVersion”, “7.1”);
ca.setCapability(“udid”, myudid);
ca.setCapability(“app”, “settings”);
URL url = new URL(“http://127.0.0.1:4723/wd/hub”);
driver = new AppiumDriver(url, ca);

Error:
Detail response:
info: --> POST /wd/hub/session {“desiredCapabilities”:{“app”:“com.apple.Preferences”,“platformVersion”:“7.1”,“deviceName”:“iPhone4”,“platformName”:“iOS”,“udid”:“d604d9e7a8b3907e1c2a9e071ea7b242823f6eb6”}}

info: Client User-Agent string: Apache-HttpClient/4.3.4 (java 1.5)
info: [debug] App is an iOS bundle, will attempt to run as pre-existing
info: [debug] Creating new appium session 4ec9788d-b5f9-42d3-9d48-b6471556b604

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 7.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 /Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/com.apple.Preferences/en.lproj/Localizable.strings
info: Will try to parse the plist file as XML
info: [debug] Could not parse plist file (as XML) at /Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/com.apple.Preferences/en.lproj/Localizable.strings
warn: Could not parse app Localizable.strings; assuming it doesn’t exist
info: [debug] Creating instruments
info: [debug] Preparing uiauto bootstrap
info: [debug] Dynamic bootstrap dir: /Users/andy/Library/Application Support/appium/bootstrap

info: [debug] Dynamic env: {“nodePath”:"/Volumes/Appium/Appium.app/Contents/Resources/node/bin/node",“commandProxyClientPath”:"/Volumes/Appium/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/andy/Library/Application Support/appium/bootstrap/bootstrap-e7c762ee10bfa027.js
info: [debug] Reusing dynamic bootstrap: /Users/andy/Library/Application Support/appium/bootstrap/bootstrap-e7c762ee10bfa027.js
info: [debug] Getting device string from opts: {“forceIphone”:false,“forceIpad”:false,“xcodeVersion”:“5.1.1”,“iOSSDKVersion”:“7.1”,“deviceName”:“iPhone4”,“platformVersion”:“7.1”}
info: [debug] fixDevice is on
info: [debug] Fixing device. Changed from: “iPhone - Simulator - iOS 7.1” to: “iPhone Retina (4-inch 64-bit) - Simulator - iOS 7.1”
info: [debug] Final device string is: ‘iPhone Retina (4-inch 64-bit) - Simulator - iOS 7.1’
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 iPhoneSimulator

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 d604d9e7a8b3907e1c2a9e071ea7b242823f6eb6
info: [debug] Couldn’t find ideviceinstaller, trying built-in at /Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/build/libimobiledevice-macosx/ideviceinstaller
info: [debug] Checking app install status using: /Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/build/fruitstrap/fruitstrap isInstalled --id d604d9e7a8b3907e1c2a9e071ea7b242823f6eb6 --bundle com.apple.Preferences

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 d604d9e7a8b3907e1c2a9e071ea7b242823f6eb6
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 d604d9e7a8b3907e1c2a9e071ea7b242823f6eb6 com.apple.Preferences -e UIASCRIPT “/Users/andy/Library/Application Support/appium/bootstrap/bootstrap-e7c762ee10bfa027.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 ] Jan 30 11:30:18 iPhone-4 DTMobileIS[3513] : Could not create service named com.apple.instruments.server.services.filebrowser

info: [IOS_SYSLOG_ROW ] Jan 30 11:30:18 iPhone-4 DTMobileIS[3513] : Could not create service named com.apple.instruments.server.services.launchdaemon

info: [IOS_SYSLOG_ROW ] Jan 30 11:30:18 iPhone-4 DTMobileIS[3513] : Could not create service named com.apple.instruments.server.services.processcontrol.posixspawn

info: [debug] [INST STDERR] 2015-01-30 11:30:19.926 instruments[2625:507] unable to locate CFBundleIdentifier for path: com.apple.Preferences

info: [debug] [INST STDERR] Instruments Trace Error : Error Starting Recording

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 iPhoneSimulator

info: Launching instruments

info: [debug] Attempting to run app on real device with UDID d604d9e7a8b3907e1c2a9e071ea7b242823f6eb6
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 d604d9e7a8b3907e1c2a9e071ea7b242823f6eb6 com.apple.Preferences -e UIASCRIPT “/Users/andy/Library/Application Support/appium/bootstrap/bootstrap-e7c762ee10bfa027.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 ] Jan 30 11:30:24 iPhone-4 mstreamd[3512] : (Note ) mstreamd: Not monitoring for external power.

info: [IOS_SYSLOG_ROW ] Jan 30 11:30:24 iPhone-4 mstreamd[3512] : (Note ) PS: Media stream daemon stopping.

info: [IOS_SYSLOG_ROW ] Jan 30 11:30:24 iPhone-4 mstreamd[3512] : (Note ) AS: <MSIOSAlbumSharingDaemon: 0x17562b90>: Shared Streams daemon has shut down.
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:24 iPhone-4 mstreamd[3512] : (Warn ) mstreamd: mstreamd shutting down.

info: [IOS_SYSLOG_ROW ] Jan 30 11:30:24 iPhone-4 mstreamd[3514] : (Note ) mstreamd: mstreamd starting up.

info: [IOS_SYSLOG_ROW ] Jan 30 11:30:24 iPhone-4 mstreamd[3514] : (Note ) PS: Media stream daemon starting…

info: [IOS_SYSLOG_ROW ] Jan 30 11:30:25 iPhone-4 DTMobileIS[3515] : Could not create service named com.apple.instruments.server.services.filebrowser

info: [IOS_SYSLOG_ROW ] Jan 30 11:30:25 iPhone-4 DTMobileIS[3515] : Could not create service named com.apple.instruments.server.services.launchdaemon

info: [IOS_SYSLOG_ROW ] Jan 30 11:30:25 iPhone-4 DTMobileIS[3515] : Could not create service named com.apple.instruments.server.services.processcontrol.posixspawn

info: [debug] [INST STDERR] 2015-01-30 11:30:27.076 instruments[2628:507] unable to locate CFBundleIdentifier for path: com.apple.Preferences

info: [debug] [INST STDERR] Instruments Trace Error : Error Starting Recording

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 iPhoneSimulator

info: [IOS_SYSLOG_ROW ] Jan 30 11:30:31 iPhone-4 mDNSResponder[33] : DeregisterInterface: Frequent transitions for interface en0 (10.100.10.120)

info: [IOS_SYSLOG_ROW ] Jan 30 11:30:31 iPhone-4 mDNSResponder[33] : mDNS_RegisterInterface: Frequent transitions for interface en0 (FE80:0000:0000:0000:049B:119E:0757:444A)

info: [IOS_SYSLOG_ROW ] Jan 30 11:30:31 iPhone-4 kernel[0] : en0: BSSID changed to b0:00:b4:fa:b1:83
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:31 iPhone-4 kernel[0] : en0::IO80211Interface::postMessage bssid changed
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:31 iPhone-4 kernel[0] : 083794.439762 wlan.N[6861] [bringUpLink] AppleBCMWLAN Left BSS(up): @0x809dea00 BSSID=b0:00:b4:fa:b1:83 rssi=-48 snr= 0 rate=54 (100%) channel= 1 encryption=0x8 ap=1 failures= 0 age=1477 ssid[11]=‘clouddevice’
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:31 iPhone-4 kernel[0] : 083794.439923 wlan.N[6862] [bringUpLink] AppleBCMWLAN Roamed to BSS: @0x809d9c00 BSSID=28:34:a2:32:54:13 rssi=-61 snr= 0 rate=54 (100%) channel=11 encryption=0x8 ap=1 failures= 0 age=1132 ssid[11]=‘clouddevice’
info: [IOS_SYSLOG_ROW ] Jan 30 11:30:31 iPhone-4 kernel[0] : en0: BSSID changed to 28:34:a2:32:54:13

info: [IOS_SYSLOG_ROW ] Jan 30 11:30:31 iPhone-4 kernel[0] : en0::IO80211Interface::postMessage bssid changed

info: [IOS_SYSLOG_ROW ] Jan 30 11:30:31 iPhone-4 mDNSResponder[33] : mDNS_RegisterInterface: Frequent transitions for interface en0 (10.100.10.120)

info: Launching instruments

info: [debug] Attempting to run app on real device with UDID d604d9e7a8b3907e1c2a9e071ea7b242823f6eb6
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 d604d9e7a8b3907e1c2a9e071ea7b242823f6eb6 com.apple.Preferences -e UIASCRIPT “/Users/andy/Library/Application Support/appium/bootstrap/bootstrap-e7c762ee10bfa027.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 ] Jan 30 11:30:32 iPhone-4 DTMobileIS[3516] : Could not create service named com.apple.instruments.server.services.filebrowser

info: [IOS_SYSLOG_ROW ] Jan 30 11:30:32 iPhone-4 DTMobileIS[3516] : Could not create service named com.apple.instruments.server.services.launchdaemon

info: [IOS_SYSLOG_ROW ] Jan 30 11:30:32 iPhone-4 DTMobileIS[3516] : Could not create service named com.apple.instruments.server.services.processcontrol.posixspawn

info: [debug] [INST STDERR] 2015-01-30 11:30:34.194 instruments[2632:507] unable to locate CFBundleIdentifier for path: com.apple.Preferences

info: [debug] [INST STDERR] Instruments Trace Error : Error Starting Recording

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 iPhoneSimulator

info: [IOS_SYSLOG_ROW ] Jan 30 11:30:35 iPhone-4 lockdownd[53] : 00201000 _select_socket: receive secure message timeout!

info: Launching instruments

info: [debug] Attempting to run app on real device with UDID d604d9e7a8b3907e1c2a9e071ea7b242823f6eb6
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 d604d9e7a8b3907e1c2a9e071ea7b242823f6eb6 com.apple.Preferences -e UIASCRIPT “/Users/andy/Library/Application Support/appium/bootstrap/bootstrap-e7c762ee10bfa027.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 ] Jan 30 11:30:40 iPhone-4 DTMobileIS[3517] : Could not create service named com.apple.instruments.server.services.filebrowser

info: [IOS_SYSLOG_ROW ] Jan 30 11:30:40 iPhone-4 DTMobileIS[3517] : Could not create service named com.apple.instruments.server.services.launchdaemon

info: [IOS_SYSLOG_ROW ] Jan 30 11:30:40 iPhone-4 DTMobileIS[3517] : Could not create service named com.apple.instruments.server.services.processcontrol.posixspawn

info: [debug] [INST STDERR] 2015-01-30 11:30:41.935 instruments[2635:507] unable to locate CFBundleIdentifier for path: com.apple.Preferences

info: [debug] [INST STDERR] Instruments Trace Error : Error Starting Recording

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

info: [debug] Killall instruments

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 iPhoneSimulator
info: [debug] Killing any other simulator daemons

info: [debug] On a real device; cannot clean device state

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

info: [debug] Cleaning up appium session

info: [debug] Error: Instruments crashed on startup
at Instruments.onInstrumentsExit (/Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:387:31)
at null. (/Volumes/Appium/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:820: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 26241.652 ms - 182

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

info: [debug] Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.3.4”,“revision”:“c8c79a85fbd6870cd6fc3d66d038a115ebe22efe”}}}
info: <-- GET /wd/hub/status 200 1.216 ms - 104 {“status”:0,“value”:{“build”:{“version”:“1.3.4”,“revision”:“c8c79a85fbd6870cd6fc3d66d038a115ebe22efe”}}}

@Andy_Zhao :- I never tried on real IOS device, So I don’t have any idea, But can you try on simulator once and check weather it is working for you or not.
Are you able to execute any other script on your real device?

Hi @Appium_Master,
thanks for your great help.

  1. Yes, I have ran other scripts in real devices
  2. I found a doc and indicate that we only can access settings page in simulator.

any update?

thanks
Andy

Just to let you know, guys. You can also run other iOS system apps using bundleId capability. Here is the list of available apps: http://stackoverflow.com/questions/9910366/what-is-the-bundle-identifier-of-apples-default-applications-in-ios

1 Like

hi @sofa,
thank you very much.
these iOS system apps can be ran in real device ? or it just can be run in simulator ?
I have tried to run it in real device, but failed.

Honestly haven’t tried that on real device yet.

Hi Andy,
I am facing the same issue while trying to run my tests against IOS real device. Are you able to solve the problem and if yes can you share with me your findings? Thanks!

Regards,
Ching

I dont think its possible.
Tried to do it and got the

info: [debug] [INST STDERR] Instruments Trace Error : Target failed to run: Permission to debug com.apple.Preferences was denied. The app must be signed with a development identity (e.g. iOS Developer).

But hope to see that theres a workaround for it.

Only work around that I know off, is using TouchAction to make some script to change whatever you want to change on settings

I need to access the ios reminder app in the real device.
Reminder is set in the reminder app from the native app that I am testing.
Can i access ios reminder app and get the list of list of reminders from appium?

I am using appium 1.6.3

How would you change the WIFI options ? I was able to successfully open settings app and click on Wifi heading but when i tried to select which Wifi I wanted to select, I was not able to do so.

Hi,

Can you please tell me how you could open the settings page on real device?

I could do it on Simulator but when I try it on real device, I could find this from the Appium logs:

[debug] [XCUITest] Cannot find xcodebuild’s process id, so unable to retrieve DerivedData folder path
[XCUITest] No WebDriverAgent derived data available, so unable to set permissions on WDA attachments folder

Yes we can do it for real devices
Add one capability “app”,”Settings”

yes , please run run the app in background and you can access any app

Hi all, I am able to navigate setting page but i want to click on Photos or general then what i have to do for ios please suggest me (setting–>Photos —> read write).

@Vikash_Narayan can you please let me know how are you navigating to the settings page of the iphone with appium

Hi… Can you please share your code snippet… I have a requirement to switch between 2 Wi-Fi network while my other iOS app is still running…