Appium Beginner Tutorial 15 | How to setup iOS Automation on Mac OS


Download

FREE courses – https://automationstepbystep.com/online-courses/
1. Java
2. Appium
3. Xcode
4. Xcode command line tools
5. WebDriverAgent
6. Real Devices OR Simulators
7. IDE (eclipse)

Step 1: Install Java JDK
Set environment variables
JAVA_HOME
PATH
java -version

Step 2: Install Homebrew
https://brew.sh/
/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
Step 3: Install node js and npm
brew install node

Step 4: Install Appium : npm install -g appium
Install Appium Desktop (optional)

Step 5: Get XCode

Xcode is the development and debug environment on Mac.
Provides required tools, files for dev/automation for Mac and iOS apps

Step 6: Install XCode command line tools
Open terminal and run
xcode-select –install

Step 7: Create Apple ID
Goto Xcode – preferences – account
Add Apple ID

Step 8: Install Carthage brew install Carthage

In order to launch WebDriverAgent, your macOS will need to have Carthage installed
(Not needed for automation on android)

Step 9: Initialize WebDriverAgent project

On terminal cd to WebDriverAgent folder

WebDriverAgent driver will be found in /path/where/installed/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
For Appium Desktop
/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent

For Appium Installed through node
/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WedDriverAgent

mkdir -p Resources/WebDriverAgent.bundle
./Scripts/bootstrap.sh -d

Note: this command needs Carthage to be installed

Step 10: Open WebDriverAgent.xcodeproj in Xcode

Project name : WebDriverAgent.xcodeproj
Location :

For Appium Desktop
/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
For Appium Installed through node
/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WedDriverAgent

https://github.com/appium/appium/issues/12586

Step 11: Under the project in Xcode
For WebDriverAgentLib and WebDriverAgentRunner targets, go to general tab and select “Automatically manage signing”, and then select your Development Team

Xcode may fail to create a provisioning profile for the WebDriverAgentRunner target:

Failed to create provisioning profile
No profile for ‘…..’ were found

manually change the bundle id for the target by going into the “Build Settings” tab, and changing the “Product Bundle Identifier” from com.facebook.WebDriverAgentRunner to something that Xcode will accept:

Going back to the “General” tab for the WebDriverAgentRunner target, you should now see that it has created a provisioning profile and all is well:

Clean – Build – Run

Finally, you can verify that everything works. Build the project:
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination ‘id=udid’ test

udid = device UDID

To get the udid of the real device connected

A9F18306-6B22-442B-99F4-F217A5EE8D38
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination ‘id=A9F18306-6B22-442B-99F4-F217A5EE8D38’ test

npm install -g ios-deploy
ios-deploy -c
OR
instruments -s devices

Step 12: Create a project and add desired capabilities for automation on iOS

deviceName
platformName
platformVersion
app

Open Eclipse
Create a new maven project or use any existing maven project
Add maven dependencies
appium
selenium

DesiredCapabilities cap = new DesiredCapabilities();

cap.setCapability(“platformName”, “iOS”);
cap.setCapability(“platformVersion”, “11.4”);
cap.setCapability(“deviceName”, “iPhone 8”);
cap.setCapability(CapabilityType.BROWSER_NAME, “safari”);
cap.setCapability(“app”, “location of .app or .ipa file“);

URL url = new URL(“http://127.0.0.1:4723/wd/hub”);

IOSDriver driver = new IOSDriver(url, cap);

References
https://github.com/appium/appium-xcuitest-driver
https://www.embarcadero.com/starthere/xe5/mobdevsetup/ios/en/signing_up_for_a_developer_account.html

External tools/utilities may be required

Install authorize-ios
npm install -g authorize-ios

Install libimobiledevice
brew install libimobiledevice

Install ideviceinstaller / ios-deploy

To deploy our apps to our devices. We can install and debug apps from the command line without using Xcode
sudo xcode-select -r
brew install ideviceinstaller

ideviceinstaller doesn’t work with iOS 10 yet. So we need to install ios-deploy
npm install -g ios-deploy

Install  ios_webkit_debug_proxy
brew install ios-webkit-debug-proxy

#AppiumBeginnerTutorials
http://bit.ly/2W9pNeb

FREE Courses – https://automationstepbystep.com/online-courses/
Raghav .

Download

source

Have any Question or Comment?

48 comments on “Appium Beginner Tutorial 15 | How to setup iOS Automation on Mac OS

Hello, Raghav! Could you help me?
How run test with iOS on a real device? I need Team ID

Reply

im very new to this 🙂 is this the way automating native IOS app?

Reply

Hello,
I am able to solve all issue and script is working fine when I use my free apple id account. but, after signing with the developer account I am unable to install WebDriverAgent on the real device.

On running xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<UDID>' test
my terminal is stuck at a point where it says "WebDriverAgentRunner-Runner[669:141632] Using singleton test manager
" and later (~30-40 minutes)i get an error

Testing failed:
WebDriverAgentRunner:
testRunner encountered an error (Encountered a problem with the test runner after launch. (Underlying error: Lost connection to DTServiceHub))

Reply

Updated path for webDriverAgent (installed using npm): /usr/local/lib/node_modules/appium/node_modules/appium-webdriveragent/

Reply

what to o if all 8 steps was successfully done but next step not? I cant find WebDriverAgent folder when I put path For Appium Desktop. Plus when I run ./Scripts/bootstrap.sh -d it is says 'no such file or directory'. Thanks for answer!

Reply

Hi Raghav,
Thanks for making the videos which are very helpful but I faced the issue when running my calculator test and it says in the console : Error: Could not find 'adb' in ["/usr/local/Caskroom/android-sdk/platform-tools/adb","/usr/local/Caskroom/android-sdk/emulator/adb","/usr/local/Caskroom/android-sdk/tools/adb","/usr/local/Caskroom/android-sdk/tools/bin/adb"]. Do you have Android Build Tools installed at '/usr/local/Caskroom/android-sdk'?
But I set the path of android home and platform-tools correctly. Can you please help me out with this error

Reply

i am unable to see web driver agent in appium i have installed appium through desktop client.

Reply

HI Raghav, Thanks for your video. Was very good to understand. i am getting error after i changed WebDriverAgentRunner in xcode as raghav123 etc as Failed to create provisioning profile.
There are no devices registered in your account on the developer website. Plug in and select a device to have Xcode register it.
any help.

Reply

Thanks for sharing.
I wonder about the apple id. It is paid account or not?. Because i tested with failure

Reply

What is -g represents in npm commands

Reply

Thanks for such a detailed video. Where do we place the IOS app file? Im very new to this

Reply

while running this command ./Scripts/bootstrap.sh -d its displays as -bash: ./scripts/bootstrap.sh: No such file or directory. Please help me to resolve this.

Reply

/Scripts/bootstrap.sh -d
does not give any output

Reply

Thanks for this vey useful video Raghav Pal. Keep up the good work..!!

Reply

Thank you for explaining so nicely. I am not able to execute it till the final step.
I performed all the steps available in the video, I used iOS in place of Android.
I got exception while running the test.

Below is the log, please check and suggest, thank you.

[RemoteTestNG] detected TestNG version 7.0.0
org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: Command 'idevice_id -l' errored out: Error: spawn idevice_id ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:262:19)
at onErrorNT (internal/child_process.js:464:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'Arpits-MBP.hsd1.ca.comcast.net', ip: '2601:646:8084:5160:0:0:0:24c4%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.1', java.version: '1.8.0_232'
Driver info: driver.version: IOSDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Command 'idevice_id -l' errored out: Error: spawn idevice_id ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:262:19)
at onErrorNT (internal/child_process.js:464:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
at getResponseForW3CError (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:826:9)
at asyncHandler (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:447:37)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'Arpits-MBP.hsd1.ca.comcast.net', ip: '2601:646:8084:5160:0:0:0:24c4%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.1', java.version: '1.8.0_232'
Driver info: driver.version: IOSDriver
at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:208)
at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:217)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:41)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.ios.IOSDriver.execute(IOSDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:336)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:37)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:88)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:98)
at io.appium.java_client.ios.IOSDriver.<init>(IOSDriver.java:90)
at tests.BaseClass.setup(BaseClass.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62)
at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:340)
at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:294)
at org.testng.TestRunner.invokeTestConfigurations(TestRunner.java:623)
at org.testng.TestRunner.beforeRun(TestRunner.java:613)
at org.testng.TestRunner.run(TestRunner.java:584)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:402)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355)
at org.testng.SuiteRunner.run(SuiteRunner.java:304)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1102)
at org.testng.TestNG.runSuites(TestNG.java:1032)
at org.testng.TestNG.run(TestNG.java:1000)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:186)
… 38 more
Caused by: org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Command 'idevice_id -l' errored out: Error: spawn idevice_id ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:262:19)
at onErrorNT (internal/child_process.js:464:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'Arpits-MBP.hsd1.ca.comcast.net', ip: '2601:646:8084:5160:0:0:0:24c4%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.1', java.version: '1.8.0_232'
Driver info: driver.version: IOSDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Command 'idevice_id -l' errored out: Error: spawn idevice_id ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:262:19)
at onErrorNT (internal/child_process.js:464:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
at getResponseForW3CError (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:826:9)
at asyncHandler (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:447:37)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:531)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
… 43 more
In side Test Now – Arpit's iPhone 8 13.1.2
PASSED: test

===============================================
Default test
Tests run: 1, Failures: 0, Skips: 0
===============================================

===============================================
Default suite
Total tests run: 1, Passes: 1, Failures: 0, Skips: 0
===============================================

Reply

For Appium Desktop
/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent

" appium-xcuitest-drive " folder is missing. Can anyone help ?

Reply

A neat explanation for the beginners. Thanks for this series. Helped a lot.

Reply

Hi Ragav, i have some problem with the WebdriverAgent folder not been created so usking mkdir WebdriverAgent, i tried reinstalling appium@1.15.0
also i installed carthage, followed all the steps mentioned. but in path i could not find WedriverAgent.
and after externally creating the folder i am not able to execute below step.

WebDriverAgent ./Scripts/bootstrap.sh -d
zsh: no such file or directory: ./Scripts/bootstrap.sh

Let me know if you need any info this issue.

Reply

Hi Ragav, really helpful 🙂

Reply

Hi Raghav ,
Can we do this ios app automation in windows 7 system. if yes , how ?

Reply

In my mac machine java -version 11 is displaying how can I download to java -version 1.8.0

Reply

Hi Raghav, Thanks for a great tutorial. However i am new to mobile testing n have few queries.
1. Application under test i.e ipa/app file should be debug mode or test?
2. I have build WDA using client provided enterprise provisioning profile and used same to code sign WDA lib and runner. When i used that profile i am able to install app and WDA on real device and simulator both. Also able to launch Integration app as well. Profile i used is associated with some “com.xxx.xxx” bundle id.
Now, main banking app under test has been developed and built with different provisioning profile and has different bundle id as compared to bundle id used for building WDA. So when i am trying to run test on simulator/real device , i pass bundle id of main app under test. Appium installs WDA and app on sim/real device but it doesn’t launch app at all. Appium server console just hangs at stage “proxying(desired capabilities ……..).
Please help me on this as i am unable to find solution on this from a week and got some hope after watching your video

Reply

I am selecting automatically signIn for target WebDriverAgentRunner but getting erro Failed to create provisioning profile.
I updated "product bundle identifier " in build setting but still facing same error

Reply

How to get .app file for any of these app for practice Make my trip, Redbus,Paytm, Zoomcar

Reply

My build keeps failing, man I don't understand why

Reply

Hey Raghav, thanks for the tutorial. When I run ./Scripts/bootstrap.sh -d in /Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent I get the same error, even though I downgraded appium just as you show here. Any thoughts?

Reply

Hi Raghav

Thanks for explaining it very well!!!

I have one issue, I am successfully able to run the project from XCode but when i am trying to run from terminal using command "xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=udid' test " then it gives the error "xcodebuild: error: ''WebDriverAgent.xcodeproj" does not exist.

Can you please help me on this.

Thanks

Reply

Why not you show step 9 for Appium for Desktop and I am getting the error as "Failed to create provisioning profile" after changing the product bundle identifier as per your instruction. I opened the WebDriverAgent.xcodeprej from appium desktop folder. Can you tell me the solution?

Reply

Thank you for that tutorial.
What I search for is testing both devices Iphone (iOS) and Samsung (Android) with
appium and VisualStudioCode on a
Windows 10 Operationg System.

Could you help me.

Reply

how to run my test written in java (eclipse+maven) in loop and break only when an error occurred and send an email for error.. thanks in advance

Reply

21:57 error message is showing even after trying several random names😔. please help

Reply

if dev team give whatsapp.app file (for example) then we need to copy to webdriveragent project under product folder …?? if yes then how to do it sir
its very imp please reply or make videos sir

Reply

Hi , How to resolve this error . "Original error: Unable to launch WebDriverAgent because of xcodebuild failure: Command 'Scripts/bootstrap.sh -d' exited with code 1" ? Thanks

Reply

Hi, How to automate REACT app on android by appium with java

Reply

Hi
Boss , How to automate REACT app on Android by appium with Java ?

Reply

Hi Raghav, I heard that appium is no longer supported for automating ios devices?Is it true?

Reply

Guys if you get an error try doing this command first: rm -rf ~/Library/Caches/org.carthage.CarthageKit and then do the bootstrap thing

Reply

Your entire video was very very useful to me, Thank you very much for sharing this video. With the help of this video I managed to solve one blocker issue in setup. Keep it up.

Reply

I am getting this error xcrun is not found is it installed ? While I try to run in simulator

Reply

Hi Raghav,
I am having Build failure, what might be the cause any idea?

Reply

Hi @Ragav i'm getting this while entering appium -v

appium -v
-bash: appium: command not found

Reply

Great video (y)

For me, WebDriverAgent was present at following path:

/Users/${USER}/node_modules/appium-webdriveragent

Reply

why i getting -bash: appium: command not found. i stuck in here can you help?

Reply

Hello Ragav, can I do appium automation testing for ios app on real device (iPhone in this case) in windows? Or I must have a Mac?

Reply

How amazingly you have explained everything! Thank you 🙂

Reply

Leave a Reply

Your email address will not be published. Required fields are marked *