Appium sample calculator test fails with ERROR: no dump file specified

Appium sample calculator test fails with ERROR: no dump file specified

我正在尝试 运行 在真实 Android 4.1.2 设备上对本机计算器应用程序进行示例测试。我在 Windows、Selendroid 和 Eclipse 上使用 Appium(运行 作为管理员)。 我的示例代码是

@BeforeClass
public void setUp() throws MalformedURLException{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("browserName", "");
capabilities.setCapability("automationName", "Selendroid");
capabilities.setCapability("platformVersion", "4.1.2");
capabilities.setCapability("deviceName","0123456789ABCDEF");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("appPackage", "com.android.calculator2");
capabilities.setCapability("appActivity","com.android.calculator2.Calculator"); 
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}

根据我在不同论坛和资源上的发现,可以仅通过其包名和启动器 activity(不提供 .apk)来引用必要的应用程序。但是,出于某种原因,Appium 在未提供转储时会失败。失败的日志是

> Checking if an update is available
> Update not available
> Starting Node Server
> info: Welcome to Appium v1.3.7 (REV 72fbfaa116d3d9f6a862600ee99cf02f6d0e2182)
> info: Appium REST http interface listener started on 127.0.0.1:4723
> info: [debug] Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"16","automationName":"Selendroid"}
> info: Console LogLevel: debug
> info: --> POST /wd/hub/session {"desiredCapabilities":{"appPackage":"com.android.calculator2","app":"Calculator.apk","appActivity":"com.android.calculator2.Calculator","BROWSER_NAME":"Chrome","platformVersion":"4.1.2","automationName":"Selendroid","platformName":"Android","deviceName":"0123456789ABCDEF"}}
> info: Client User-Agent string: Apache-HttpClient/4.3.6 (java 1.5)
> info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : BROWSER_NAME
> info: [debug] App is an Android package, will attempt to run on device
> info: [debug] Creating new appium session 9942d26b-d1c1-43c8-9c6b-a9c4382d5ac9
> info: [debug] Starting selendroid server
> info: [debug] Getting Java version
> info: Java version is: 1.8.0_45
> info: [debug] Checking whether adb is present
> info: [debug] Using adb from D:\Android\android-sdk\platform-tools\adb.exe
> info: [debug] Checking whether selendroid is built yet
> info: [debug] Selendroid server exists!
> info: [debug] Using fast reset? true
> info: [debug] Preparing device for session
> info: [debug] Not checking whether app is present since we are assuming it's already on the device
> info: Retrieving device
> info: [debug] Trying to find a connected android device
> info: [debug] Getting connected devices...
> info: [debug] executing cmd: D:\Android\android-sdk\platform-tools\adb.exe devices
> info: [debug] 1 device(s) connected
> info: Found device 0123456789ABCDEF
> info: [debug] Setting device id to 0123456789ABCDEF
> info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
> info: [debug] executing cmd: D:\Android\android-sdk\platform-tools\adb.exe -s 0123456789ABCDEF wait-for-device
> info: [debug] executing cmd: D:\Android\android-sdk\platform-tools\adb.exe -s 0123456789ABCDEF shell "echo 'ready'"
> info: [debug] Starting logcat capture
> info: [debug] Checking whether aapt is present
> info: [debug] Using aapt from D:\Android\android-sdk\build-tools.0.1\aapt.exe
> info: [debug] Checking if has internet permission from manifest.
> info: [debug] executing cmd: D:\Android\android-sdk\build-tools.0.1\aapt.exe dump badging 
> warn: ERROR: no dump file specified
> 
> error: Failed to start an Appium session, err was: Error: hasInternetPermissionFromManifest failed. Error: Command failed: ERROR: no dump file specified
> 
> info: [debug] Cleaning up appium session
> info: [debug] Error: hasInternetPermissionFromManifest failed. Error: Command failed: ERROR: no dump file specified
> 
>     at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:1661:19
>     at ChildProcess.exithandler (child_process.js:641:7)
>     at ChildProcess.EventEmitter.emit (events.js:98:17)
>     at maybeClose (child_process.js:743:16)
>     at Process.ChildProcess._handle.onexit (child_process.js:810:5)
> info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: hasInternetPermissionFromManifest failed. Error: Command failed: ERROR: no dump file specified\r\n)","origValue":"hasInternetPermissionFromManifest failed. Error: Command failed: ERROR: no dump file specified\r\n"},"sessionId":null}
> info: <-- POST /wd/hub/session 500 635.247 ms - 318

有解决办法吗?

此代码适用于我的 Android 设备。我能够启动计算器应用 w/o apk 路径。

DesiredCapabilities capabilities = new DesiredCapabilities();

capabilities.setCapability("appium-version", "1.1.0");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName", "my_device_name");
capabilities.setCapability("platformVersion", "4.4");
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("device", "Android");
capabilities.setCapability("appPackage", "com.android.calculator2");
capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");
serverAddress = new URL("http://127.0.0.1:4723/wd/hub");
driver = new AndroidDriver(serverAddress, capabilities);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

这是我能够弄清楚的:

  1. 请注意我是 运行 Android 4.1.2 并且必须使用 Selendroid
  2. Selendroid requires 应用的 <uses-permission android:name="android.**permission.INTERNET"/> 权限
  3. 这里我猜测是,然后用aapt解析.apk文件,因为
  4. 一旦我提供了从 phone 中提取的 .apk 文件,它实际上会转到下一步,解析清单并寻找许可

总结一下:如果我使用 Selendroid,我必须提供 .apk 并且我的 .apk 必须具有互联网许可。这就是计算器测试在这里不起作用的原因。

我想如果我们重建apk,问题就会得到解决。我过去遇到过这个问题,在重建 apk 后我能够解决它。

问候 詹内斯瓦尔