appium环境搭建可参考以下两个链接:www.jianshu.com/p/a2b79cd8b…www.jianshu.com/p/3c04e029c…
环境配置:
carthage: stable 0.31.2 (bottled), HEAD usbmuxd: stable 1.0.10 (bottled), HEAD libimobiledevice: stable 1.2.0 (bottled), HEAD npm 6.4.1 ios-deploy 1.9.4 xcpretty 0.3.0 appium-doctor 1.6.0 Appium v1.9.1 Python 3.7 WebDriverAgent 用GitHub的[github.com/facebook/We… ] Xcode10.1
每次真机开发启动顺序: 1.先在终端启动WDA(或者直接用XCode直接【WebDriverAgentRunner】-【testing】也行)
xcodebuild build-for-testing test-without-building -project /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination id=设备ID test
进行端口转发
iproxy 8100 8100 设备ID
- 启动Appium Server
配置信息:
"deviceName": "iPhone 6s", "platformName": "ios", "udid": "601861ce25a7dae4dc3d12e6f43cd42936XXXXXX", "automationName": "XCUITest", "xcodeOrgId": " 7GTPKLXXXX", "xcodeSigningId": "iPhone Developer", "no-reset": true, "startIWDP": true, "bundleId": "com.XXXXXX"
- 通过元素定位器进行定位
- python通过appium进行脚本编写
遇到的坑:
- 运行安装WebDriverAgent验证是否安装成功:
export DEVICE_URL='http://localhost:8100' export JSON_HEADER='-H "Content-Type: application/json;charset=UTF-8, accept: application/json"' curl -X GET $JSON_HEADER $DEVICE_URL/status
或
http://localhost:8100/status
如果单纯WebDriverAgent运行成功,然后appuim没有反应,可能因为有些国产的iPhone设备通过手机的IP和端口还不能访问,此时需要将手机的端口转发到Mac上 : 终端输入:iproxy 8100 8100
- 如果存在多个版本Xcode,在安装brew包的时候,会出现兼容性问题,可以通过切换来处理
sudo xcode-select --switch /Applications/Xcode9.4.1.app sudo xcode-select --switch /Applications/Xcode.app
- 两个wda模块地址 1、在命令行安装appium的时候已经集成了wda模块
/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj
2、使用appium desktop的wda模块
/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
- 出现报错:
A new session could not be created. Details: Appium's IosDriver does not support Xcode version 9.4.1. Apple has deprecated UIAutomation. Use the "XCUITest" automationName capability instead.
- 解决办法:添加 automationName = XCUITest
- 出现报错:
An unknown server-side error occurred while processing the command. Original error: Unknown device or simulator UDID
- 解决办法:
- 安装libimobiledevice
brew install --HEAD libimobiledevice
- 出现报错:
Requested 'libusbmuxd >= 1.1.0' but version of libusbmuxd is 1.0.10 Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables libusbmuxd_CFLAGS and libusbmuxd_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.
- 解决办法:
brew update brew uninstall --ignore-dependencies libimobiledevice brew uninstall --ignore-dependencies usbmuxd brew install --HEAD usbmuxd brew unlink usbmuxd brew link usbmuxd brew install --HEAD libimobiledevice
- 出现报错
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=4723): Max retries exceeded with url: /wd/hub/session (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x109c28908>: Failed to establish a new connection: [Errno 61] Connection refused'))
解决办法:打开appium-desktop