mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 23:51:25 +08:00
fix: sleep specified seconds
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
|||||||
"github.com/electricbubble/gwda"
|
"github.com/electricbubble/gwda"
|
||||||
cvHelper "github.com/electricbubble/opencv-helper"
|
cvHelper "github.com/electricbubble/opencv-helper"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TemplateMatchMode is the type of the template matching operation.
|
// TemplateMatchMode is the type of the template matching operation.
|
||||||
@@ -170,6 +171,7 @@ func (dExt *DriverExt) takeScreenShot() (raw *bytes.Buffer, err error) {
|
|||||||
return dExt.frame, nil
|
return dExt.frame, nil
|
||||||
}
|
}
|
||||||
if raw, err = dExt.WebDriver.Screenshot(); err != nil {
|
if raw, err = dExt.WebDriver.Screenshot(); err != nil {
|
||||||
|
log.Error().Err(err).Msgf("screenshot failed: %v", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|||||||
+9
-4
@@ -1,6 +1,7 @@
|
|||||||
package hrp
|
package hrp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -241,7 +242,7 @@ func (s *StepIOS) Times(n int) *StepIOS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sleep specify sleep seconds after last action
|
// Sleep specify sleep seconds after last action
|
||||||
func (s *StepIOS) Sleep(n int) *StepIOS {
|
func (s *StepIOS) Sleep(n float64) *StepIOS {
|
||||||
s.step.IOS.Actions = append(s.step.IOS.Actions, MobileAction{
|
s.step.IOS.Actions = append(s.step.IOS.Actions, MobileAction{
|
||||||
Method: ctlSleep,
|
Method: ctlSleep,
|
||||||
Params: n,
|
Params: n,
|
||||||
@@ -707,11 +708,15 @@ func (ud *uiDriver) doAction(action MobileAction) error {
|
|||||||
param := fmt.Sprintf("%v", action.Params)
|
param := fmt.Sprintf("%v", action.Params)
|
||||||
return ud.SendKeys(param)
|
return ud.SendKeys(param)
|
||||||
case ctlSleep:
|
case ctlSleep:
|
||||||
if param, ok := action.Params.(int); ok {
|
if param, ok := action.Params.(json.Number); ok {
|
||||||
time.Sleep(time.Duration(param) * time.Second)
|
seconds, _ := param.Float64()
|
||||||
|
time.Sleep(time.Duration(seconds*1000) * time.Millisecond)
|
||||||
|
return nil
|
||||||
|
} else if param, ok := action.Params.(float64); ok {
|
||||||
|
time.Sleep(time.Duration(param*1000) * time.Millisecond)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fmt.Errorf("invalid sleep params: %v", action.Params)
|
return fmt.Errorf("invalid sleep params: %v(%T)", action.Params, action.Params)
|
||||||
case ctlScreenShot:
|
case ctlScreenShot:
|
||||||
// take snapshot
|
// take snapshot
|
||||||
log.Info().Msg("take snapshot for current screen")
|
log.Info().Msg("take snapshot for current screen")
|
||||||
|
|||||||
Reference in New Issue
Block a user