-1

我正在使用 Appium Desktop 客户端 1.7.1 和服务器 1.9.1 和 eclipse 在 Windows 和 MacOS 上运行测试脚本。

我使用 Java 编写我的测试脚本和带有 maven、junit 4.12 和 appium java-client 6.0.1 的项目

我首先使用 Android Studio 3.2.1 在模拟器 SDK 28 上运行 android 应用程序,然后在桌面客户端中启动 appium 服务器,然后在 eclipse 中启动我的测试脚本。

在模拟器中安装了一些 appium helper 应用程序后,出现以下错误。

[UiAutomator2] Forwarding UiAutomator2 Server port 6790 to 8200
[ADB] Forwarding system: 8200 to device: 6790
[ADB] Running 'D:\Users\User\Documents\android-sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 forward tcp\:8200 tcp\:6790'
[ADB] Running 'D:\Users\User\Documents\android-sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell rm -rf /data/local/tmp/strings.json'
[ADB] Running 'D:\Users\User\Documents\android-sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell pm path com.apps.appium'
[ADB] Running 'D:\Users\User\Documents\android-sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell pm path com.apps.appium'
[UiAutomator2] Deleting UiAutomator2 session
[UiAutomator2] Deleting UiAutomator2 server session
[JSONWP Proxy] Matched '/' to command name 'deleteSession'
[UiAutomator2] Did not get confirmation UiAutomator2 deleteSession worked; Error was: UnknownError: An unknown server-side error occurred while processing the command. Original error: Trying to proxy a session command without session id
[ADB] Running 'D:\Users\User\Documents\android-sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 shell am force-stop com.apps.appium'
[Logcat] Stopping logcat capture
[ADB] Removing forwarded port socket connection: 8200 
[ADB] Running 'D:\Users\User\Documents\android-sdk\platform-tools\adb.exe -P 5037 -s emulator-5554 forward --remove tcp\:8200'
[BaseDriver] Event 'newSessionStarted' logged at 1539620644423 (00:24:04 GMT+0800 (China Standard Time))
[W3C] Encountered internal error running command: Error: Error executing adbExec. Original error: 'Command 'D\:\\Users\\User\\Documents\\android-sdk\\platform-tools\\adb.exe -P 5037 -s emulator-5554 shell pm path com.apps.appium' exited with code 1'; Stderr: ''; Code: '1'
[W3C]     at ADB.execFunc$ (C:\Users\User\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\system-calls.js:327:13)
[W3C]     at tryCatch (C:\Users\User\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
[W3C]     at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\User\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
[W3C]     at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (C:\Users\User\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
[W3C]     at GeneratorFunctionPrototype.invoke (C:\Users\User\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[W3C]     at 
[HTTP] <-- POST /wd/hub/session 500 3687 ms - 1925

似乎拉命令失败。这是我的能力

capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName","Android");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("appPackage", "com.apps.appium");
capabilities.setCapability("automationName", "UiAutomator2");
capabilities.setCapability("appActivity", ".MainActivity");
capabilities.setCapability("no-reset", "true");

任何人都可以帮忙吗?也许我错过了什么?

4

1 回答 1

1

你为什么不为此使用直接的appium方法pullFile。以下是不同类型文件的使用示例

@Test
public void pullTextFileFromMobileSDCardTest() throws IOException {
    byte[] returnData = _driver.pullFile("/storage/sdcard1/mili_log.txt");
    //System.out.println(" Printing Text of File received from mobile :: " + new String(Base64.decodeBase64(returnData)));
    File fs = new File("C:\\eclipse\\MobileFile.txt");
    FileOutputStream fos = new FileOutputStream(fs);
    fos.write(returnData);
    fos.flush();
    fos.close();
}   

  @Test     
  public void pullImageFileFromMobileSDCardTest() throws IOException {
      byte[] returnData = 
    _driver.pullFile("/storage/sdcard1/IMG_20140828_072840.jpg");
   //System.out.println("Base 64 Converted String received from mobile :: " + returnData);
    BufferedImage image=ImageIO.read(new ByteArrayInputStream(returnData));
    ImageIO.write(image, "jpg", new File("C:\\eclipse","snap.jpg"));
 }

 @Test
  public void pullVideoFileFromMobileSDCardTest() throws IOException {
        byte[] returnData = _driver.pullFile("/storage/sdcard1/VideoIconfile.mp4");
       //System.out.println(" Printing Text of File received from mobile :: " + new String(Base64.decodeBase64(returnData)));
        FileOutputStream fos = new FileOutputStream("C:\\eclipse\\video.mp4");
        fos.write(returnData);
        fos.flush();
        fos.close();
  }     
于 2018-10-15T20:07:12.613 回答