无法在Android 7.0上运行appium测试

时间:2017-02-16 20:26:14

标签: android appium

我在Android 7.0真实设备(Nexus 6)上运行测试时遇到问题 Appium版本:1.6.3 操作系统:Windows 10 语言:Java Java客户端:4.1.2

有趣的是,当我插入任何Android 6设备(将platformVersion设置为6.0)时 - 测试运行没有问题。但是当我尝试在Android 7.0设备上运行它时,我收到错误。

以下是我在Android 7.0上运行的功能:

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "Android");
capabilities.setCapability("browserName", "Android");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "7.0");
capabilities.setCapability("fullReset", true);
capabilities.setCapability("autoAcceptAlerts", true);
capabilities.setCapability("newCommandTimeout", 0);
capabilities.setCapability("app", "C:\Apk\xxx-release.apk");
capabilities.setCapability("appPackage", "com.xxx.android.vvm");
capabilities.setCapability("appActivity", "com.xxx.android.vvm.activity.Splash");

以下是IDE控制台输出中的日志:

    Feb 14, 2017 4:21:19 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
Feb 14, 2017 4:21:24 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to original OSS JSON Wire Protocol.
Feb 14, 2017 4:21:29 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to straight W3C remote end connection

org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{app=C:\Apk\xxx-release.apk, appPackage=com.xxx.android.vvm, appActivity=com.xxx.android.vvm.activity.Splash, newCommandTimeout=0, platformVersion=7.0, browserName=Android, platformName=Android, deviceName=Android, fullReset=true, autoAcceptAlerts=true}], required capabilities = Capabilities [{}]
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'TAC-45', ip: '10.3.184.68', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_111'
Driver info: driver.version: AndroidDriver

at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)

以下是服务器日志:

[debug] [AndroidDriver] Not cleaning generated files. Add clearSystemFiles capability if wanted.
[MJSONWP] Encountered internal error running command: Error: Error executing adbExec. Original error: 'Command 'C\:\Android\sdk\platform-tools\adb.exe -P 5037 -s ZX1G22D7HJ install C\:\Users\user\AppData\Roaming\npm\node_modules\appium\node_modules\io.appium.settings\bin\settings_apk-debug.apk' exited with code 1'; Stderr: 'Failed to install C:\Users\user\AppData\Roaming\npm\node_modules\appium\node_modules\io.appium.settings\bin\settings_apk-debug.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package io.appium.settings signatures do not match the previously installed version; ignoring!]'; Code: '1'
at ADB.execFunc$ (../../../lib/tools/system-calls.js:195:13)
at tryCatch (C:\Users\user\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke as _invoke
at GeneratorFunctionPrototype.prototype.(anonymous function) as throw
at GeneratorFunctionPrototype.invoke (C:\Users\user\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
at process.tickCallback (internal/process/nexttick.js:103:7)
[HTTP] <-- POST /wd/hub/session 500 4879 ms - 754
[HTTP] --> POST /wd/hub/session {"capabilities":{"desiredCapabilities":{"app":"C:\Apk\xxx-release.apk","appPackage":"com.xxx.android.vvm","appActivity":"com.xxx.android.vvm.activity.Splash","newCommandTimeout":0,"platformVersion":"7.0","browserName":"Android","platformName":"Android","deviceName":"Android","fullReset":true,"autoAcceptAlerts":true},"requiredCapabilities":{}}}
[debug] [MJSONWP] Bad parameters: BadParametersError: Parameters were incorrect. We wanted {"required":["desiredCapabilities"],"optional":["requiredCapabilities","capabilities","sessionId","id","sessionId","id","sessionId","id"]} and you sent ["capabilities"]

似乎功能出错。但是,当我使用Android 6插入手机并将platformVersion设置为6.0时,所有测试都运行没有问题!

我将不胜感激。

5 个答案:

答案 0 :(得分:5)

删除&#34;解锁&#34;和&#34; Appium设置&#34;来自设备的应用程序 - Appium会自动安装这些应用程序。 (在我的原因中,将Android从版本6更新到版本7后,这些应用程序不兼容。

答案 1 :(得分:0)

您可以发布Java客户端版本吗?

注意:尝试使用最新的稳定Java客户端版本。

https://mvnrepository.com/artifact/io.appium/java-client/4.1.2

答案 2 :(得分:0)

删除尝试每次在设备上安装的“应用”功能。而是在设备上手动安装应用程序并尝试。如果它不起作用,让我知道还有一个解决方案,但我建议你先尝试一下。

答案 3 :(得分:0)

错误日志显示

[INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package io.appium.settings signatures do not match the previously installed version;

通常这些错误是由于在设备上签署了发布版本,然后尝试在顶部部署调试版本。它被卡在一个无法完全卸载的无效状态。

由于这些原因,您的会话未创建,为了避免这些,请卸载设备上存在的应用程序然后运行脚本。它应该可以工作。

希望这些可以帮助你。

答案 4 :(得分:0)

如果遇到此错误,请使用Android Studio从测试设备中卸载所有工件。打开Android studio右侧的Gradle视图。

打开:应用&gt;任务&gt;双击安装并运行uninstallAll任务