一. Appium 根据 desired capabilities 连接终端的关键步骤
在之前的系列文章 Android-APPUI自动化搭建步骤 中, 我们定义了如下的 desired capabilities (相关参数在本文中已脱敏):
{
"platformName": "Android",
"platformVersion": "11", // Android 版本
"appPackage": " your app ", // app 包名 (需改成你自己的)
"appActivity": "your activity", // 自动化打开 app 初始的的页面名, 须改成你自己的
"noReset": "True", // 表示每次打开 app 不清空用户信息
"udid": "vgorl7pjcu55uwp7" // 真机唯一设备 id
}
试截取连接终端时 Appium Desktop 中显示的部分关键日志, 分析 desired capabilities 的作用
1.客户端与Appium 服务端建立连接 (其实这里还没有用到 desired capabilities, 只是 appium inspector 这个客户端根据默认的 appium server 地址: 127.0.0.1:4723 建立的 http 连接)
[BaseDriver] Creating session with MJSONWP desired capabilities: {
[BaseDriver] "appActivity": "xxxxxxxxxxxxxxxxxxx",
[BaseDriver] "appPackage": "xxxxxxxxxxxxxxxx",
[BaseDriver] "ensureWebviewsHavePages": true,
[BaseDriver] "noReset": "True",
[BaseDriver] "platformName": "Android",
[BaseDriver] "platformVersion": "11",
[BaseDriver] "udid": "vgorl7pjcu55uwp7",
[BaseDriver] "newCommandTimeout": 0,
[BaseDriver] "connectHardwareKeyboard": true
[BaseDriver] }
[BaseDriver] Capability 'noReset' changed from string to boolean. This may cause unexpected behavior
[BaseDriver] The following capabilities were provided, but are not recognized by Appium:
[BaseDriver] connectHardwareKeyboard