新手区 [求助]appium 用 selendroid 模式的话,使用截图 (get_screenshot_as_png),得到的文件是坏的文件

敏敏 · 2016年05月05日 · 最后由 敏敏 回复于 2016年05月05日 · 1656 次阅读

appium 用 selendroid 模式的话,使用截图(get_screenshot_as_png),得到的文件是裂图。但是用 uiautomator 模式的话,正常的获取截图。请问一下为什么

脚本如下:

png =self.driver.get_screenshot_as_png()
 with open(r'./snapshot/2.png', 'wb') as f:
       f.write(png)
 self.driver.find_element_by_id("login").click()

当执行

png =self.driver.get_screenshot_as_png()
 with open(r'./snapshot/2.png', 'wb') as f:
       f.write(png)

这脚本的时候,保存的图片无法打开
appium 的输出

info: <-- POST /wd/hub/session 303 13852.217 ms - 74
info: --> GET /wd/hub/session/c280aadf-e288-0593-c314-053a47d1665b {}
info: [debug] Proxying command to localhost:4444
info: [debug] Making http request with opts: {"url":"http://localhost:4444/wd/hub/session/c280aadf-e288-0593-c314-053a47d1665b,method:GET"}
info: [debug] Proxied response received with status 200: {"value":{"automationName":"selendroid","platform":"android","app":"/Users/zhouminyi/Downloads/Friday.apk","acceptSslCerts":true,"javascriptEnabled":true,"browserName":"selendroid","appActivity":"com.xtuone.android.friday.InitActivity","networkConnectionEnabled":true,"rotatable":true,"desired":{"automationName":"Selendroid","app":"/Users/zhouminyi/Downloads/Friday.apk","deviceName":"","platformName":"Android","appActivity":"com.xtuone.android.friday.InitActivity","unicodeKeyboard":true,"resetKeyboard":true,"appPackage":"com.xtuone.android.syllabus","plateformVersion":"4.4.4"},"appPackage":"com.xtuone.android.syllabus","version":"0.16.0","platformVersion":"19","deviceName":"","platformName":"android","handlesAlerts":true,"unicodeKeyboard":true,"resetKeyboard":true,"warnings":{},"takesScreenshot":true,"plateformVersion":"4.4.4"},"status":0,"sessionId":"c280aadf-e288-0593-c314-053a47d1665b"}
info: <-- GET /wd/hub/session/c280aadf-e288-0593-c314-053a47d1665b 200 29.406 ms - 901

info: --> GET /wd/hub/session/c280aadf-e288-0593-c314-053a47d1665b/screenshot {}

当执行完保存图片的时候,再次执行操作

self.driver.find_element_by_id("login").click()

同时如果执行截图后,再次执行点击(click()) 等方法,
appium 后台报错显示

Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command.","origValue":"Did not successfully proxy server command"},"sessionId":"c280aadf-e288-0593-c314-053a47d1665b"}
info: <-- POST /wd/hub/session/c280aadf-e288-0593-c314-053a47d1665b/element 500 40.707 ms - 210

控制台输出报错:

WebDriverException: Message: An unknown server-side error occurred while processing the command.

是不是 selendroid 的情况下,无法保存图片

共收到 4 条回复 时间 点赞

appium 用 selenium 模式的话

这是什么模式?

对不起,打错啦

log 和截图都提供下,不要一句话

appium 的输出

info: <-- POST /wd/hub/session 303 13852.217 ms - 74
info: --> GET /wd/hub/session/c280aadf-e288-0593-c314-053a47d1665b {}
info: [debug] Proxying command to localhost:4444
info: [debug] Making http request with opts: {"url":"http://localhost:4444/wd/hub/session/c280aadf-e288-0593-c314-053a47d1665b,method:GET"}
info: [debug] Proxied response received with status 200: {"value":{"automationName":"selendroid","platform":"android","app":"/Users/zhouminyi/Downloads/Friday.apk","acceptSslCerts":true,"javascriptEnabled":true,"browserName":"selendroid","appActivity":"com.xtuone.android.friday.InitActivity","networkConnectionEnabled":true,"rotatable":true,"desired":{"automationName":"Selendroid","app":"/Users/zhouminyi/Downloads/Friday.apk","deviceName":"","platformName":"Android","appActivity":"com.xtuone.android.friday.InitActivity","unicodeKeyboard":true,"resetKeyboard":true,"appPackage":"com.xtuone.android.syllabus","plateformVersion":"4.4.4"},"appPackage":"com.xtuone.android.syllabus","version":"0.16.0","platformVersion":"19","deviceName":"","platformName":"android","handlesAlerts":true,"unicodeKeyboard":true,"resetKeyboard":true,"warnings":{},"takesScreenshot":true,"plateformVersion":"4.4.4"},"status":0,"sessionId":"c280aadf-e288-0593-c314-053a47d1665b"}
info: <-- GET /wd/hub/session/c280aadf-e288-0593-c314-053a47d1665b 200 29.406 ms - 901

info: --> GET /wd/hub/session/c280aadf-e288-0593-c314-053a47d1665b/screenshot {}

同时如果执行截图后,再次执行点击(click()) 等方法,
appium 后台报错显示

Responding to client with error: {"status":13,"value":{"message":"An unknown server-side error occurred while processing the command.","origValue":"Did not successfully proxy server command"},"sessionId":"c280aadf-e288-0593-c314-053a47d1665b"}
info: <-- POST /wd/hub/session/c280aadf-e288-0593-c314-053a47d1665b/element 500 40.707 ms - 210

控制台输出报错:

WebDriverException: Message: An unknown server-side error occurred while processing the command.

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