Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.takeScreenshot() 截图方法win10环境下的支持bug #103

Closed
Archer456 opened this issue Aug 9, 2016 · 16 comments
Closed

.takeScreenshot() 截图方法win10环境下的支持bug #103

Archer456 opened this issue Aug 9, 2016 · 16 comments
Assignees
Labels

Comments

@Archer456
Copy link

Archer456 commented Aug 9, 2016

https://testerhome.com/topics/5641 请看下如此在win10环境下 脚本里的
.takeScreenshot() 截图方法,实际看日志应该是 执行adb pull 命令报错了 无法复制到win10环境下的
C:\Users\cmd\AppData\Local\Temp\ 目录下。

`>> responseHandler.js:50:12 [master] pid:10376 Send Error Respone to Client: Error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c "D:\Android\android-sdk-windows/platform-tools/adb -s 192.168.236.101:5555 pull /data/local/tmp/screenshot.png C:\Users\cmd\AppData\Local\Temp\macaca-android-screenshot11679-10376-cm89un.png"

responseHandler.js:56:14 [master] pid:10376 Error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c "D:\Android\android-sdk-windows/platform-tools/adb -s 192.168.236.101:5555 pull /data/local/tmp/screenshot.png C:\Users\cmd\AppData\Local\Temp\macaca-android-screenshot11679-10376-cm89un.png"`

  1. macaca mobile sample 请求提供一个Android 端 demo~ #2 should display 我的page:
    Error: [takeScreenshot()] Not JSON response
    at exports.newError (D:\macaca\me-app\node_modules\macaca-wd\wd\lib\utils.js:139:13)
    at D:\macaca\me-app\node_modules\macaca-wd\wd\lib\callbacks.js:59:17
    at D:\macaca\me-app\node_modules\macaca-wd\wd\lib\webdriver.js:179:5
    at Request._callback (D:\macaca\me-app\node_modules\macaca-wd\wd\lib\http-utils.js:87:7)
    at Request.self.callback (D:\macaca\me-app\node_modules\macaca-wd\node_modules\request\request.js:368:22)
    at Request. (D:\macaca\me-app\node_modules\macaca-wd\node_modules\request\request.js:1219:14)
    at IncomingMessage. (D:\macaca\me-app\node_modules\macaca-wd\node_modules\request\request.js:1167:12)
    at endReadableNT (_stream_readable.js:921:12)

我是可以手动命令cp该文件,并查看到最后一个截图是正常的
C:\Users\cmd>adb pull /data/local/tmp/screenshot.png D:
[100%] /data/local/tmp/screenshot.png

这应该是.takeScreenshot() 截图方法 在win环境下的命令拼接错误bug吧。

@ziczhu
Copy link
Member

ziczhu commented Aug 16, 2016

@Archer456 你直接执行报错的那句,可以执行吗

C:\WINDOWS\system32\cmd.exe /s /c "D:\Android\android-sdk-windows/platform-tools/adb -s 192.168.236.101:5555 pull /data/local/tmp/screenshot.png C:\Users\cmd\AppData\Local\Temp\macaca-android-screenshot11679-10376-cm89un.png

我看上面你手动的命令除了 -s 192.168.236.101:5555 这个选项其他都是一样的。

@Archer456
Copy link
Author

@zenzhu 是可以直接cmd里执行的 输出如图
image

我继续
C:\Users\cmd>adb pull /data/local/tmp/screenshot.png D:
[100%] /data/local/tmp/screenshot.png

down到 D:\ 截图也是正常的

@ziczhu
Copy link
Member

ziczhu commented Aug 16, 2016

@Archer456 看了一下 应该是这行的问题 https://github.com/macacajs/macaca-adb/blob/master/lib/helper.js#L107 windows 应该是 backslash,这个倒不是问题,主要是代码中要对 backslash 转义。

@Archer456
Copy link
Author

@zenzhu 好 找到问题修复就好

下边的这个 也是日志里报的错 你也正好一起看了吧
3) #5 Edit and Login

responseHandler.js:11:12 [master] pid:10376 Recieve HTTP Request from Client: method: DELETE url: /wd/hub/session/b7ff1a6b-c532-40fe-b5c8-074f24b2d0b0, jsonBody: {}
macaca-android.js:60:14 [master] pid:10376 Error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c "D:\Android\android-sdk-windows/platform-tools/adb emu kill"
error: no emulator detected

at ChildProcess.exithandler (child_process.js:213:12)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:827:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

session.js:80:12 [master] pid:10376 Delete session, sessionId: b7ff1a6b-c532-40fe-b5c8-074f24b2d0b0
responseHandler.js:43:14 [master] pid:10376 Send HTTP Respone to Client: {"sessionId":"b7ff1a6b-c532-40fe-b5c8-074f24b2d0b0","status":0}

@xudafeng
Copy link
Member

@zenzhu windows有 gitbash和cmd两种,都需要转义吗?

@Archer456
Copy link
Author

@zenzhu 能解决就都解决呗 都转更好。支持的更多。

@Archer456
Copy link
Author

Archer456 commented Aug 16, 2016

@zenzhu 不过 我还是不清楚 截图后的文件 怎么在本地项目里找到或本机测试环境下找到。
能带些参数吗 让脚本编辑人员自行指定 保存路径 图片属性格式 什么的等参数

@ziczhu
Copy link
Member

ziczhu commented Aug 16, 2016

@Archer456 用 saveScreenshot 是可以指定目录的

@ziczhu
Copy link
Member

ziczhu commented Aug 16, 2016

@Archer456 在 win7 上测试了一下,那个转义的代码取环境变量的时候自动转了,所以应该不是这个问题。而且 win7 上这段代码我运行了一下也是没有问题的,不太确定这个究竟是什么导致的了,是不是 win10 独有的问题。

@ziczhu
Copy link
Member

ziczhu commented Aug 16, 2016

@Archer456 adb emu kill 就是关闭模拟器的时候发现模拟器已经不存在了,有没有可能是用例代码中关闭了多次模拟器,不过这个错误可以忽略,不重要。

@Archer456
Copy link
Author

Archer456 commented Aug 16, 2016

@zenzhu win10 独有的问题? 不应该吧 你再看看 testerhome那个链接里的日志。https://testerhome.com/topics/5641

  1. aicai-sample 请求提供一个Android 端 demo~ #2 should display 我的page:
    Error: [takeScreenshot()] Not JSON response
    at exports.newError (D:\macaca\me-app\node_modules\macaca-wd\wd\lib\utils.js:139:13)
    at D:\macaca\me-app\node_modules\macaca-wd\wd\lib\callbacks.js:59:17
    at D:\macaca\me-app\node_modules\macaca-wd\wd\lib\webdriver.js:179:5
    at Request._callback (D:\macaca\me-app\node_modules\macaca-wd\wd\lib\http-utils.js:87:7)
    at Request.self.callback (D:\macaca\me-app\node_modules\macaca-wd\node_modules\request\request.js:368:22)
    at Request. (D:\macaca\me-app\node_modules\macaca-wd\node_modules\request\request.js:1219:14)
    at IncomingMessage. (D:\macaca\me-app\node_modules\macaca-wd\node_modules\request\request.js:1167:12)
    at endReadableNT (_stream_readable.js:921:12)

这里

@xudafeng
Copy link
Member

@zenzhu 截图的问题修复了吗?

@Archer456
Copy link
Author

image

在手机里的。。。
/data/local/tmp/screenshot.png下

1而ubuntu下日志里 没见有执行 driver.takeScreenshot(); 的相关输出日志 ,这个应该有吧.

windows下 能看到日志 里有相关的takeScreenshot方法执行的 命令 但是win10下还是报错的
#103 看这个issue

2这个 .takeScreenshot(); 方法 不能指定存放路径吗 我们都想转存到本机项目环境下的实际.

3 java里 点不出 saveScreenshot方法
image

@Archer456
Copy link
Author

已经有高人解决了.加了savescreenshot方法了 坐等更新吧

@xudafeng
Copy link
Member

xudafeng commented Sep 1, 2016

问题初步定为是这里导致 https://github.com/macacajs/macaca-android/blob/master/lib/controllers.js#L145 @zenzhu 还需要继续定为根本原因,修复

@xudafeng
Copy link
Member

xudafeng commented Sep 7, 2016

@xudafeng xudafeng closed this as completed Sep 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants