mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-08 00:47:36 +08:00
feat: add video crawler
This commit is contained in:
+22
-10
@@ -39,6 +39,7 @@ const (
|
||||
CtlStopCamera MobileMethod = "camera_stop" // alias for app_terminate camera
|
||||
RecordStart MobileMethod = "record_start"
|
||||
RecordStop MobileMethod = "record_stop"
|
||||
VideoCrawler MobileMethod = "video_crawler"
|
||||
|
||||
// UI validation
|
||||
// selectors
|
||||
@@ -657,6 +658,27 @@ func (dExt *DriverExt) DoAction(action MobileAction) error {
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid sleep random params: %v(%T)", action.Params, action.Params)
|
||||
}
|
||||
return sleepRandom(params)
|
||||
case CtlScreenShot:
|
||||
// take screenshot
|
||||
log.Info().Msg("take screenshot for current screen")
|
||||
_, err := dExt.TakeScreenShot(builtin.GenNameWithTimestamp("step_%d_screenshot"))
|
||||
return err
|
||||
case CtlStartCamera:
|
||||
return dExt.Driver.StartCamera()
|
||||
case CtlStopCamera:
|
||||
return dExt.Driver.StopCamera()
|
||||
case VideoCrawler:
|
||||
params, ok := action.Params.(map[string]interface{})
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid video crawler params: %v(%T)", action.Params, action.Params)
|
||||
}
|
||||
return dExt.VideoCrawler(params)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func sleepRandom(params []interface{}) error {
|
||||
// append default weight 1
|
||||
if len(params) == 2 {
|
||||
params = append(params, 1.0)
|
||||
@@ -701,16 +723,6 @@ func (dExt *DriverExt) DoAction(action MobileAction) error {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
case CtlScreenShot:
|
||||
// take screenshot
|
||||
log.Info().Msg("take screenshot for current screen")
|
||||
_, err := dExt.TakeScreenShot(builtin.GenNameWithTimestamp("step_%d_screenshot"))
|
||||
return err
|
||||
case CtlStartCamera:
|
||||
return dExt.Driver.StartCamera()
|
||||
case CtlStopCamera:
|
||||
return dExt.Driver.StopCamera()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package uixt
|
||||
|
||||
func (dExt *DriverExt) VideoCrawler(params map[string]interface{}) error {
|
||||
return nil
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
type MobileStep struct {
|
||||
Serial string `json:"serial,omitempty" yaml:"serial,omitempty"`
|
||||
Serial string `json:"serial,omitempty" yaml:"serial,omitempty"` // android serial or ios udid
|
||||
uixt.MobileAction `yaml:",inline"`
|
||||
Actions []uixt.MobileAction `json:"actions,omitempty" yaml:"actions,omitempty"`
|
||||
}
|
||||
@@ -293,6 +293,14 @@ func (s *StepMobile) SleepRandom(params ...float64) *StepMobile {
|
||||
return &StepMobile{step: s.step}
|
||||
}
|
||||
|
||||
func (s *StepMobile) VideoCrawler(params map[string]interface{}) *StepMobile {
|
||||
s.mobileStep().Actions = append(s.mobileStep().Actions, uixt.MobileAction{
|
||||
Method: uixt.VideoCrawler,
|
||||
Params: params,
|
||||
})
|
||||
return &StepMobile{step: s.step}
|
||||
}
|
||||
|
||||
func (s *StepMobile) ScreenShot() *StepMobile {
|
||||
s.mobileStep().Actions = append(s.mobileStep().Actions, uixt.MobileAction{
|
||||
Method: uixt.CtlScreenShot,
|
||||
|
||||
Reference in New Issue
Block a user