这里不在赘述mac端的环境搭建,感兴趣的可以参照(搭建mac端Appium环境)
1、在mac端,使用”Appium Server GUI“成功启动Appium服务:
2、iphone设备通过usb连接mac电脑,Xcode成功运行WebDriverAgentRunner服务到iphone设备
3、执行python代码,创建session并启动iphone上的app
网上找的python代码:
desired_capabilities_tmp = {
"udid": "你iphone的udid",
"platformName": "iOS",# iOS平台,也可换成Android
"platformVersion": "14.0.1", #iphone的系统版本
"bundleId": "测试app的bundleID",
'deviceName': "iphone 7",# iphone的设备名称
}
driver = webdriver.Remote(command_executor='http://0.0.0.0:8100/wd/hub',desired_capabilities=desired_capabilities_tmp)
执行报错:
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Unhandled endpoint: /wd/hub/session -- http://0.0.0.0:8100/ with parameters {
wildcards = (
"wd/hub/session"
);
}
We've got an error while stopping in post-mortem: <class 'KeyboardInterrupt'>
第一次尝试使用Appium,没啥经验,最终解决问题,成功启动app, 是url地址的问题,改为'http://0.0.0.0:8100' :
desired_capabilities_tmp = {
"udid": "你iphone的udid",
"platformName": "iOS",# iOS平台,也可换成Android
"platformVersion": "14.0.1", #iphone的系统版本
"bundleId": "测试app的bundleID",
'deviceName': "iphone 7",# iphone的设备名称
}
driver = webdriver.Remote(command_executor='http://0.0.0.0:8100',desired_capabilities=desired_capabilities_tmp)
总结
在网上找到的启动地址都类似 'http://0.0.0.0:8100/wd/hub' ,包含"/wd/hub",在iOS端测试一直失败,因此尝试修改了url地址,这可能是跟Appium的版本有关系。我这里用的版本信息如下:
其他依赖库的版本信息:
Package Version
-------------------- ---------
Appium-Python-Client 2.1.2
async-generator 1.10
pycparser 2.21
setuptools 60.9.3