mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-25 17:44:02 +08:00
feat: add function call for XTDriver
This commit is contained in:
@@ -1 +1 @@
|
||||
v5.0.0-beta-2505100001
|
||||
v5.0.0-beta-2505100950
|
||||
|
||||
@@ -335,9 +335,10 @@ func (dExt *XTDriver) DoAction(action MobileAction) (err error) {
|
||||
case ACTION_ClosePopups:
|
||||
return dExt.ClosePopupsHandler()
|
||||
case ACTION_CallFunction:
|
||||
fn := action.Fn
|
||||
fn()
|
||||
return nil
|
||||
if funcDesc, ok := action.Params.(string); ok {
|
||||
return dExt.Call(funcDesc, action.Fn)
|
||||
}
|
||||
return fmt.Errorf("invalid function description: %v", action.Params)
|
||||
case ACTION_AIAction:
|
||||
if prompt, ok := action.Params.(string); ok {
|
||||
return dExt.AIAction(prompt, action.GetOptions()...)
|
||||
|
||||
@@ -29,7 +29,7 @@ func (dExt *XTDriver) TapByOCR(text string, opts ...option.ActionOption) error {
|
||||
point = textRect.Center()
|
||||
}
|
||||
log.Info().Str("text", text).Interface("rawTextRect", textRect).
|
||||
Interface("tapPoint", point).Msg("TapByOCR success")
|
||||
Interface("tapPoint", point).Msg("TapByOCR")
|
||||
|
||||
return dExt.TapAbsXY(point.X, point.Y, opts...)
|
||||
}
|
||||
@@ -52,7 +52,7 @@ func (dExt *XTDriver) TapByCV(opts ...option.ActionOption) error {
|
||||
point = uiResult.Center()
|
||||
}
|
||||
log.Info().Interface("rawUIResult", uiResult).
|
||||
Interface("tapPoint", point).Msg("TapByCV success")
|
||||
Interface("tapPoint", point).Msg("TapByCV")
|
||||
|
||||
return dExt.TapAbsXY(point.X, point.Y, opts...)
|
||||
}
|
||||
|
||||
@@ -1,10 +1,23 @@
|
||||
package uixt
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/httprunner/httprunner/v5/uixt/option"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
// Call custom function, used for pre/post hook for actions
|
||||
func (dExt *XTDriver) Call(desc string, fn func()) error {
|
||||
startTime := time.Now()
|
||||
fn()
|
||||
log.Info().Str("desc", desc).
|
||||
Int64("duration(ms)", time.Since(startTime).Milliseconds()).
|
||||
Msg("function called")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func preHandler_TapAbsXY(driver IDriver, options *option.ActionOptions, rawX, rawY float64) (
|
||||
x, y float64, err error) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user