Requirements:
- OS X Yosemite 10.10.5
- Xcode 7.2.1
- iOS Device (9.2.1)
- Homebrew
- Git
- SafariLauncher
- Appium (1.4.16)
- Apple ID with *Provisioning Profile (iOS Development)
*Note: Free iOS Development Provisioning Profile can be created via Xcode 7
I. Create iOS Development Provisioning Profile for SafariLauncher
- Clone https://github.com/budhash/SafariLauncher.git
- Open the project in Xcode
- Open Xcode > Preferences > Accounts
- Add an Apple ID
- Click the apple id and click View Details
- Create iOS Development Signing Identities
II. Create Provisioning Profile for SafariLauncher
- Using the same xcode project, provide ‘Bundle Identifier’ value.
i.e.com.github.blago.SafariLauncher
- Fix the issue with Provisioning Profile
- After fixing the issue, provide deployment information
- For Xcode 7.2.1, click Build Settings and edit Code Signing section
- Build and run SafariLauncher on the iOS Device
- Trust the developer of the app in the iOS Device.
Go to Settings > General > Device Management
III. Build SafariLauncher for Real Devices (using appium source)
- Clone https://github.com/appium/appium.git
- SHA-1 hash used: 54c2b4e6500eddbca4bb3047116ceb8d177f7294
- git checkout 54c2b4e6500eddbca4bb3047116ceb8d177f7294
- Go to the appium directory (clone) and edit reset.sh then provide the BUNDLE_ID used in the provisioning profile
- Run the command inside the appium directory
./reset.sh --ios --real-safari --verbose
IV. Install Homebrew Packages
- Do the following command
brew update
brew install libimobiledevice libplist libtasn1 usbmuxd openssl ideviceinstaller
brew install ios-webkit-debug-proxy
brew install node
V. iOS Device Configuration
- Enable UI Automation (Settings > Developer)
- Turn on Safari Web Inspector (Settings > Safari > Advanced)
VI. Appium Server Configuration
- Start ios_webkit_debug_proxy
ios_webkit_debug_proxy -c <iOS_SERIAL_NUMBER>:27753
- Start the sever inside the appium directory
node . -U <iOS_SERIAL_NUMBER> --app 'safari' --command-timeout 120
iOS_SERIAL_NUMBER can be found in
About This Mac > Overview > System Report > Hardware > USB
VII. Code Configuration
String hubUrl = "http://127.0.0.1:4723/wd/hub"; String iOSBrowserName = "Safari"; String iOSDeviceName = "<iOS_SERIAL_NUMBER>"; String iOSVersion = “9.2”; DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("deviceName", iOSDeviceName); capabilities.setCapability("platformName", "iOS"); capabilities.setCapability("platformVersion", iOSVersion); capabilities.setCapability("browserName", iOSBrowserName); WebDriver driver = new RemoteWebDriver(new URL(hubUrl), capabilities);
VIII. Possible Runtime Errors
- FBSOpenApplicationErrorDomain error
info: [debug] [INST STDERR] Instruments Trace Error : Target failed to run: The operation couldn’t be completed. (FBSOpenApplicationErrorDomain error 3.) : Failed to launch process with bundle identifier ‘com.github.blago.SafariLauncher'
Solution:
Trust the developer who signed the SafariLauncher app (Settings > General > Device Management)
- ideviceinstaller error
Error: Command failed: /bin/sh -c ideviceinstaller
Solution:
Select the target device in Xcode for the SafariLauncher then restart the appium node.
IX. Sample Appium Server Output with iOS Device Screen
- On standby, waiting for test to run
- Test executed, SafariLauncher started on iOS device.
- Actual test being executed, application under test is m.facebook.com
Click here to watch the execution.
Thanks for visiting my blog!