Appium [已解决]Appium 在 retina iPad take screenshot 時 timeout

Giga · 2014年07月17日 · 最后由 恒温 回复于 2014年08月16日 · 2622 次阅读

同樣的 code, 在 iPad2 上運行沒問題, 在 iPad3 上運行到 take screenshot 時就錯誤
log 顯示 command timeout, 似乎是因為 retina device 圖像比較大所以複製稍微慢了一點就 timeout?
不知道有沒有人有解決的辦法, 感謝

appium log:

debug: Socket data received (25 bytes)
debug: Socket data being routed.
debug: Got result from instruments: {"status":0,"value":""}
debug: Responding to client with success: {"status":0,"value":"","sessionId":"0de2d378-ebfa-41ba-8caf-2407726b0454"}
info: <-- POST /wd/hub/session/0de2d378-ebfa-41ba-8caf-2407726b0454/element/2/click 200 1314.346 ms - 74 {"status":0,"value":"","sessionId":"0de2d378-ebfa-41ba-8caf-2407726b0454"}
info: --> GET /wd/hub/session/0de2d378-ebfa-41ba-8caf-2407726b0454/screenshot {}
debug: Pushing command to appium work queue: "au.getScreenOrientation()"
debug: Sending command to instruments: au.getScreenOrientation()
debug: Sending command to instruments: au.getScreenOrientation()
debug: [INST] 2014-07-17 06:40:22 +0000 Debug: evaluation finished

debug: [INST] 2014-07-17 06:40:22 +0000 Debug: responding with:

debug: [INST] 2014-07-17 06:40:22 +0000 Debug: Running system command #10: /usr/local/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":""}...

debug: [INST] 2014-07-17 06:40:27 +0000 Debug: Got new command 10 from instruments: au.getScreenOrientation()

debug: [INST] 2014-07-17 06:40:27 +0000 Debug: evaluating au.getScreenOrientation()

debug: [INST] 2014-07-17 06:40:27 +0000 Debug: evaluation finished

debug: [INST] 2014-07-17 06:40:27 +0000 Debug: responding with:

debug: [INST] 2014-07-17 06:40:27 +0000 Debug: Running system command #11: /usr/local/bin/node /usr/local/lib/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js /tmp/instruments_sock 2,{"status":0,"value":"PORTRAIT"}...

debug: Socket data received (33 bytes)
debug: Socket data being routed.
debug: Got result from instruments: {"status":0,"value":"PORTRAIT"}
debug: Setting internal orientation to PORTRAIT
debug: Pushing command to appium work queue: "au.capture('screenshot18e6ea0d-da2f-401f-92e0-e7bf05c80daa')"
debug: Sending command to instruments: au.capture('screenshot18e6ea0d-da2f-401f-92e0-e7bf05c80daa')
debug: Sending command to instruments: au.capture('screenshot18e6ea0d-da2f-401f-92e0-e7bf05c80daa')
debug: [INST] 2014-07-17 06:40:28 +0000 Debug: Got new command 11 from instruments: au.capture('screenshot18e6ea0d-da2f-401f-92e0-e7bf05c80daa')

debug: [INST] 2014-07-17 06:40:28 +0000 Debug: evaluating au.capture('screenshot18e6ea0d-da2f-401f-92e0-e7bf05c80daa')

debug: [INST] 2014-07-17 06:40:28 +0000 Debug: target.captureRectWithName("{origin:{x:0.00,y:0.00}, size:{height:1024.00,width:768.00}}", "screenshot18e6ea0d-da2f-401f-92e0-e7bf05c80daa")


debug: Socket data received (25 bytes)
debug: Socket data being routed.
debug: Got result from instruments: {"status":0,"value":""}
debug: Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command. (Original error: Timed out waiting for screenshot file. Error: ENOENT, open '/tmp/appium-instruments/Run 1/screenshotf4cfdde6-894f-4eff-8621-e71f7d16aabf.png')","origValue":"Timed out waiting for screenshot file. Error: ENOENT, open '/tmp/appium-instruments/Run 1/screenshotf4cfdde6-894f-4eff-8621-e71f7d16aabf.png'"},"sessionId":"b941e4fa-cbdc-4392-ae9a-29cf5c64e98c"}
info: <-- GET /wd/hub/session/b941e4fa-cbdc-4392-ae9a-29cf5c64e98c/screenshot 500 9846.702 ms - 470 

screenshot code

public static void screenshot() {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String dateString = sdf.format(date);
        File srcFile = (File) (((TakesScreenshot) wd).getScreenshotAs(OutputType.FILE));
        try {
            FileUtils.copyFile(srcFile, new File("/Users/Documents/screenshot/" + dateString + ".jpg"));
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

參考資料:
https://groups.google.com/forum/#! searchin/appium-discuss/screenshot$20timeout/appium-discuss/VhQ0-ULEAgQ/Kh_rcvXdKzoJ

有人說修改 appium 參數即可, 可是不知道要修改哪個檔案的參數?

appium version 1.2

共收到 3 条回复 时间 点赞
Giga #1 · 2014年07月17日 Author

update:

似乎是 screenshot 沒有複製到電腦上, 不確定是什麼原因, 這邊也有一個有同樣問題的

https://github.com/appium/appium/issues/3130

Giga #2 · 2014年08月15日 Author

*update

Github 上已經有人修復了這個 bug,如果有人也有同樣問題可以參考 Github 上的 code

https://github.com/moizjv/appium/commit/3eb3914707098b1d2a089a9f53fd1597cc7d1235

#2 楼 @gigayaya 谢谢,帮你修改下标题。

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册