mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-10 23:12:41 +08:00
feat: add video crawler
This commit is contained in:
@@ -39,6 +39,7 @@ const (
|
|||||||
CtlStopCamera MobileMethod = "camera_stop" // alias for app_terminate camera
|
CtlStopCamera MobileMethod = "camera_stop" // alias for app_terminate camera
|
||||||
RecordStart MobileMethod = "record_start"
|
RecordStart MobileMethod = "record_start"
|
||||||
RecordStop MobileMethod = "record_stop"
|
RecordStop MobileMethod = "record_stop"
|
||||||
|
VideoCrawler MobileMethod = "video_crawler"
|
||||||
|
|
||||||
// UI validation
|
// UI validation
|
||||||
// selectors
|
// selectors
|
||||||
@@ -657,6 +658,27 @@ func (dExt *DriverExt) DoAction(action MobileAction) error {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("invalid sleep random params: %v(%T)", action.Params, action.Params)
|
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
|
// append default weight 1
|
||||||
if len(params) == 2 {
|
if len(params) == 2 {
|
||||||
params = append(params, 1.0)
|
params = append(params, 1.0)
|
||||||
@@ -701,16 +723,6 @@ func (dExt *DriverExt) DoAction(action MobileAction) error {
|
|||||||
return nil
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
5
hrp/pkg/uixt/video_crawler.go
Normal file
5
hrp/pkg/uixt/video_crawler.go
Normal file
@@ -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 {
|
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"`
|
uixt.MobileAction `yaml:",inline"`
|
||||||
Actions []uixt.MobileAction `json:"actions,omitempty" yaml:"actions,omitempty"`
|
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}
|
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 {
|
func (s *StepMobile) ScreenShot() *StepMobile {
|
||||||
s.mobileStep().Actions = append(s.mobileStep().Actions, uixt.MobileAction{
|
s.mobileStep().Actions = append(s.mobileStep().Actions, uixt.MobileAction{
|
||||||
Method: uixt.CtlScreenShot,
|
Method: uixt.CtlScreenShot,
|
||||||
|
|||||||
Reference in New Issue
Block a user