mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-30 12:59:39 +08:00
fix: swipe with params
This commit is contained in:
@@ -306,6 +306,13 @@ func (dExt *XTDriver) DoAction(action MobileAction) (err error) {
|
||||
} else if sd, ok := action.Params.(SleepConfig); ok {
|
||||
sleepStrict(sd.StartTime, int64(sd.Seconds*1000))
|
||||
return nil
|
||||
} else if param, ok := action.Params.(string); ok {
|
||||
seconds, err := builtin.ConvertToFloat64(param)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "invalid sleep params: %v(%T)", action.Params, action.Params)
|
||||
}
|
||||
time.Sleep(time.Duration(seconds*1000) * time.Millisecond)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("invalid sleep params: %v(%T)", action.Params, action.Params)
|
||||
case ACTION_SleepMS:
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"math/rand/v2"
|
||||
|
||||
"github.com/httprunner/httprunner/v5/internal/builtin"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
type ActionOptions struct {
|
||||
@@ -72,10 +73,22 @@ func (o *ActionOptions) Options() []ActionOption {
|
||||
case []interface{}:
|
||||
// loaded from json case
|
||||
// custom direction: [fromX, fromY, toX, toY]
|
||||
sx, _ := builtin.Interface2Float64(v[0])
|
||||
sy, _ := builtin.Interface2Float64(v[1])
|
||||
ex, _ := builtin.Interface2Float64(v[2])
|
||||
ey, _ := builtin.Interface2Float64(v[3])
|
||||
sx, err := builtin.Interface2Float64(v[0])
|
||||
if err != nil {
|
||||
log.Error().Err(err).Interface("fromX", v[0]).Msg("convert float64 failed")
|
||||
}
|
||||
sy, err := builtin.Interface2Float64(v[1])
|
||||
if err != nil {
|
||||
log.Error().Err(err).Interface("fromY", v[1]).Msg("convert float64 failed")
|
||||
}
|
||||
ex, err := builtin.Interface2Float64(v[2])
|
||||
if err != nil {
|
||||
log.Error().Err(err).Interface("toX", v[2]).Msg("convert float64 failed")
|
||||
}
|
||||
ey, err := builtin.Interface2Float64(v[3])
|
||||
if err != nil {
|
||||
log.Error().Err(err).Interface("toY", v[3]).Msg("convert float64 failed")
|
||||
}
|
||||
options = append(options, WithCustomDirection(
|
||||
sx, sy,
|
||||
ex, ey,
|
||||
|
||||
Reference in New Issue
Block a user