appium环境搭建可参考以下两个链接: https://www.jianshu.com/p/a2b79cd8bf38 https://www.jianshu.com/p/3c04e029c3ea
环境配置: 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的[https://github.com/facebook/WebDriverAgent ] Xcode10.1
每次真机开发启动顺序: 1.先在终端启动WDA(或者直接用XCode直接【WebDriverAgentRunner】-【testing】也行)
代码语言:javascript复制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
进行端口转发
代码语言:javascript复制iproxy 8100 8100 设备ID
- 启动Appium Server
Appium Server.png
配置信息:
代码语言:javascript复制 "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
或
代码语言:javascript复制http://localhost:8100/status
如果单纯WebDriverAgent运行成功,然后appuim没有反应,可能因为有些国产的iPhone设备通过手机的IP和端口还不能访问,此时需要将手机的端口转发到Mac上 : 终端输入:iproxy 8100 8100 <DeviceUDID>
- 如果存在多个版本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模块
代码语言:javascript复制/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