我正在将Appium桌面客户端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
似乎pull命令失败。这是我的能力
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");
有人可以帮忙吗?也许我错过了什么?
答案 0 :(得分:0)
您为什么不使用直接鸦片方法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();
}