How to get started appium using Xcuitest for real device.
I found there are a lot of duplicated question about xcuitest and appium 1.6 beta in here. but most of questions about this still no good answer. so I decide to write a tutorials for everyone who don't know how to get started appium using Xcuitest.
Let's go ahead to see.
0. Preparation
Firstly make sure your node >=4 and npm>=3 before you install appium beta version using npm.
1. Install appium v1.6
npm3 install -g appium@beta
2. Install dependencies
brew install ideviceinstaller
brew install carthage
npm install -g ios-deploy
3. Launch appium server
appium
4. Write script using appium python-binding.
Remember set automationName as "XCUITest",
and you also need set realDeviceLogger as idevicesyslog.
from appium import webdriver
import os
app_path = "<your app path>"
udid = "<your udid>"
platformVersion = "<your platform version>"
deviceName = "<your device name>"
success = True
desired_caps = {}
desired_caps['platformName'] = 'iOS'
desired_caps['platformVersion'] = platformVersion
desired_caps['deviceName'] = deviceName
desired_caps['udid'] = udid
desired_caps['automationName'] = 'XCUITest'
desired_caps['realDeviceLogger'] = 'idevicesyslog'
desired_caps['app'] = os.path.abspath(app_path)
wd = webdriver.Remote('http://0.0.0.0:4723/wd/hub', desired_caps)
wd.implicitly_wait(60)
try:
wd.find_element_by_xpath("//XCUIElementTypeButton[@name='OK']").click()
wd.find_element_by_xpath("//XCUIElementTypeTextField[1]").send_keys("123")
finally:
wd.quit()
if not success:
raise Exception("Test failed.")
5. Update your device info and run the script.
Note:
Remeber you have to change all UIA to XCUIElementType when you create xpath expression, for example:
UIAButton --> XCUIElementTypeButton
UIAXXX --> XCUIElementTypeXXX
Some Problems:
How to solve slow appium tests on OSX 10.12 Sierra? ( Dezik provided )