mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-07 16:59:34 +08:00
fix: screencap compatibility for shell v1 and v2
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
- fix: stop logcat only when enabled
|
- fix: stop logcat only when enabled
|
||||||
- fix: do not fail case when kill logcat error
|
- fix: do not fail case when kill logcat error
|
||||||
- fix: take screenshot after each step
|
- fix: take screenshot after each step
|
||||||
|
- fix: screencap compatibility for shell v1 and v2
|
||||||
|
|
||||||
## v4.3.2 (2022-12-26)
|
## v4.3.2 (2022-12-26)
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
v4.3.3.2304142149
|
v4.3.3.2304142356
|
||||||
@@ -572,5 +572,20 @@ func (d *Device) Uninstall(packageName string, keepData ...bool) (string, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Device) ScreenCap() ([]byte, error) {
|
func (d *Device) ScreenCap() ([]byte, error) {
|
||||||
return d.RunShellCommandWithBytes("screencap", "-p")
|
if d.HasFeature(FeatShellV2) {
|
||||||
|
return d.RunShellCommandV2WithBytes("screencap", "-p")
|
||||||
|
}
|
||||||
|
|
||||||
|
// for shell v1, screenshot buffer maybe truncated
|
||||||
|
// thus we firstly save it to local file and then pull it
|
||||||
|
tempPath := fmt.Sprintf("/data/local/tmp/screenshot_%d.png",
|
||||||
|
time.Now().Unix())
|
||||||
|
_, err := d.RunShellCommandWithBytes("screencap", "-p", tempPath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer := bytes.NewBuffer(nil)
|
||||||
|
err = d.Pull(tempPath, buffer)
|
||||||
|
return buffer.Bytes(), err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user