feat: add adb screen record

This commit is contained in:
lilong.129
2025-03-06 16:57:51 +08:00
parent 5b503a4394
commit cc81c00a82
14 changed files with 159 additions and 43 deletions
+4 -1
View File
@@ -875,10 +875,13 @@ func (wd *WDADriver) triggerWDALog(data map[string]interface{}) (rawResp []byte,
return wd.Session.POST(data, "/gtf/automation/log")
}
func (wd *WDADriver) ScreenRecord(duration time.Duration) (videoPath string, err error) {
func (wd *WDADriver) ScreenRecord(opts ...option.ActionOption) (videoPath string, err error) {
timestamp := time.Now().Format("20060102_150405") + fmt.Sprintf("_%03d", time.Now().UnixNano()/1e6%1000)
fileName := filepath.Join(config.GetConfig().ScreenShotsPath, fmt.Sprintf("%s.mp4", timestamp))
options := option.NewActionOptions(opts...)
duration := time.Duration(options.Duration * float64(time.Second))
file, err := os.Create(fileName)
if err != nil {
fmt.Println("Error creating file:", err)