Appium [求助] appium1.6.3 设置了属性 capabilities.setCapability ("automationName","uiautomator2"),无法启动 driver

songer · 2017年05月05日 · 最后由 songer 回复于 2017年05月05日 · 1796 次阅读

环境
appium1.6.3
jdk1.8
java-client 5.0.0-BETA3
selenium 3.0.1

测试代码:

protected AndroidDriver driver;
@Parameters({ "serverIP","port", "platformName","udid",
"appPackage", "appActivity" })
@BeforeTest
public void setUp(String serverIP,String port,String platformName,String udid,
String appPackage,String appActivity) throws Exception {

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("platformName", platformName);
capabilities.setCapability("deviceName", udid);
capabilities.setCapability("udid", udid);
capabilities.setCapability("platformVersion", "6.0");
capabilities.setCapability("unicodeKeyboard", true);
capabilities.setCapability("resetKeyboard", true);
capabilities.setCapability("noReset", true);
capabilities.setCapability("noSign", true);
capabilities.setCapability("appPackage", appPackage);
capabilities.setCapability("appActivity", appActivity);
capabilities.setCapability("automationName","uiautomator2");
driver = new AndroidDriver(new URL("http://" + serverIP + ":" + port + "/wd/hub"),capabilities);
}

增加这句 capabilities.setCapability("automationName","uiautomator2");,无法启动 app 测试,也没办法安装 io.appium.uiautomator2.server 和
io.appium.uiautomator2.server.test 这两个 apk,去掉又正常

部分报错信息如下:
ADB] No io.appium.uiautomator2.server process found to kill, continuing...
[debug] [UiAutomator2] Forwarding UiAutomator2 Server port 6790 to 8200
[debug] [ADB] Forwarding system: 8200 to device: 6790
[debug] [ADB] Running 'D:\andriod\android-sdk-windows\platform-tools\adb.exe' wi
th args: ["-P",5037,"-s","WTKDU16707010313","forward","tcp:8200","tcp:6790"]
[debug] [UiAutomator2] No app capability. Assuming it is already on the device
[debug] [AndroidDriver] Running fast reset (stop and clear)
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\andriod\android-sdk-windows\platform-tools\adb.exe' wi
th args: ["-P",5037,"-s","WTKDU16707010313","shell","pm","clear","com.fxi.s
ml"]
[debug] [ADB] APK doesn't exist. null
[ADB] Checking whether aapt is present
[ADB] Using aapt.exe from D:\andriod\android-sdk-windows\build-tools\19.0.3\aapt
.exe
[debug] [ADB] Getting install status for io.appium.uiautomator2.server
[debug] [ADB] Device API level: 23
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\andriod\android-sdk-windows\platform-tools\adb.exe' wi
th args: ["-P",5037,"-s","WTKDU16707010313","shell","pm","list","packages","-3",
"io.appium.uiautomator2.server"]
[debug] [ADB] App is not installed
[debug] [ADB] Checking app cert for C:\Users\Administrator\AppData\Roaming\npm\n
ode_modules\appium\node_modules\appium-uiautomator2-driver\uiautomator2\appium-u
iautomator2-server-v0.0.8.apk.
[debug] [ADB] App already signed.
[debug] [ADB] Zip-aligning 'C:\Users\Administrator\AppData\Roaming\npm\node_modu
les\appium\node_modules\appium-uiautomator2-driver\uiautomator2\appium-uiautomat
or2-server-v0.0.8.apk'
[ADB] Checking whether zipalign is present
[debug] [ADB] App not signed with debug cert.
[debug] [ADB] Resigning apk.
[debug] [ADB] Zip-aligning 'C:\Users\Administrator\AppData\Roaming\npm\node_modu
les\appium\node_modules\appium-uiautomator2-driver\uiautomator2\appium-uiautomat
or2-server-v0.0.8.apk'
[ADB] Checking whether zipalign is present
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [UiAutomator2] Deleting UiAutomator2 server session
[UiAutomator2] Did not get confirmation UiAutomator2 deleteSession worked; Error
was: Error: Trying to proxy a session command without session id
[debug] [ADB] Getting connected devices...
[debug] [UiAutomator2] Deleting UiAutomator2 session
[debug] [UiAutomator2] Deleting UiAutomator2 server session
[UiAutomator2] Did not get confirmation UiAutomator2 deleteSession worked; Error
大家有没有遇到过,以上还需要配置什么,我就上面这种环境,加了 capabilities.setCapability("automationName","uiautomator2");,然后启动 appium,然后进行测试,是否少什么配置?关于兼容性我考虑过了 appium1.6.4 也试过了,java-client 和 selenium 都试了好几个版本

共收到 1 条回复 时间 点赞

自己找到原因了,谢谢大家

songer 关闭了讨论 05月05日 23:38
songer 重新开启了讨论 05月08日 10:08
songer 关闭了讨论 05月08日 10:09
songer 重新开启了讨论 05月08日 10:22
songer 关闭了讨论 05月08日 10:23
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册