在調試安卓設備的時候出現這樣的報錯:
Matched W3C error code 'unable to capture screen' to UnableToCaptureScreen
[WD Proxy] Matched '/wd/hub/session/fe541bfa-6b17-4aad-a327-b4a688261ec6/window/current/size' to command name 'getWindowSize'
[WD Proxy] Proxying [GET /wd/hub/session/fe541bfa-6b17-4aad-a327-b4a688261ec6/window/current/size] to [GEThttp://127.0.0.1:8200/wd/hub/session/269e635c-10ef-48c8-8989-c2b408faccc2/window/current/size] with body: {}
[MJSONWP (fe541bfa)] Encountered internal error running command: io.appium.uiautomator2.common.exceptions.TakeScreenshotException: Failed to capture a screenshot. Does the current view have 'secure' flag set?
可以先試試
adb shell screencap -p /sdcard/screen.png
看當前頁面是否可以截圖保存在手機的scard頁面。如果可以先排除app本身的問題,如果用這個命令都沒有截圖保存在手機,那麼有可能當前app本身的問題。
還有一種就是安卓手機當前頁面如果有系統鍵盤的存在,也是會出現這種報錯。(點擊屏幕,把系統鍵盤隱藏在定位就搞定了)