-1

I am using Appium Desktop client 1.7.1 with server 1.9.1 and eclipse to run the test script on both Windows and MacOS.

I using Java to write my test script and the project with maven, junit 4.12 and appium java-client 6.0.1

I using Android Studio 3.2.1 to run the android app on emulator SDK 28 first, then start appium server in the desktop client, then start my test script in eclipse.

After it installed some appium helper app in the emulator, it has the below errors.

[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

Seems the pull command is failed. and here is my capabilities

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");

Can anyone help? Maybe I missed somethings?

Chiman
  • 163
  • 2
  • 4
  • 11

1 Answers1

1

Why don't you use direct appium method pullFile for this. Below are the usage example for different types of files

@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();
  }     
Amit Jain
  • 4,389
  • 2
  • 18
  • 21
  • You mean I should try to use `app` to install the apk directly instead of trying to launch the app that existing in the devices? – Chiman Oct 16 '18 at 05:17
  • Yes because you may always required latest build which may not be available on mobile. – Amit Jain Oct 16 '18 at 06:31