一、环境搭建
1.安装appium2
npm i -g appium@next
2.安装Appium驱动程序及其依赖项
appium driver install uiautomator2
appium driver install xcuitest
3.安装appium-inspector
Releases · appium/appium-inspector (github.com)
注意appium2.0版本已经不支持网页访问inspector,需要下载官方客户端
4.配置WebDriverAgent
appium driver run xcuitest open-wda
修改bundleid, comand+u运行到真机
5.安装Appium python模块
pip3 install Appium-Python-Client
6.运行appium服务
打开命令行, 输入
appium
7.打开Appium inspector
输入配置
8.编写python脚本,运行测试用例
from appium import webdriver
from appium.options.common.base import Appium
Optionsoptions = AppiumOptions()
options.load_capabilities({
"platformName": "iOS",
"appium:platformVersion": "16.7.8",
"appium:bundleId": "xxxx",
"appium:automationName": "XCUITest",
"appium:uid": "auto", "appium:autoAcceptAlerts":
True, "appium:deviceName": "Alvin8P", "
appium:udid": "52068287ad86c0fbb6cc97ecec4caff9f78c72ad",
"appium:includeSafariInWebviews": True, "appium:newCommandTimeout": 3600,
"appium:connectHardwareKeyboard": True})
appium_server_url = 'http://127.0.0.1:4723'
driver = webdriver.Remote(appium_server_url, options=options)