mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-25 09:33:43 +08:00
refactor: move uixt from hrp internal to pkg
This commit is contained in:
34
examples/uixt/demo_test.go
Normal file
34
examples/uixt/demo_test.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package uixt
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||
)
|
||||
|
||||
func TestDemo(t *testing.T) {
|
||||
device, err := uixt.NewIOSDevice(uixt.WithWDAPort(8700), uixt.WithWDAMjpegPort(8800))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
driverExt, err := uixt.InitWDAClient(device)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// 持续监测手机屏幕,直到出现青少年模式弹窗后,点击「我知道了」
|
||||
for {
|
||||
_, err1 := driverExt.GetTextXY("青少年模式")
|
||||
point, err2 := driverExt.GetTextXY("我知道了")
|
||||
if err1 != nil || err2 != nil {
|
||||
time.Sleep(1 * time.Second)
|
||||
continue
|
||||
}
|
||||
|
||||
err := driverExt.TapAbsXY(point.X, point.Y, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/uixt"
|
||||
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||
)
|
||||
|
||||
func format(data map[string]string) string {
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/uixt"
|
||||
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||
)
|
||||
|
||||
type Device struct {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
giDevice "github.com/electricbubble/gidevice"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/uixt"
|
||||
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||
)
|
||||
|
||||
var iosRootCmd = &cobra.Command{
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/uixt"
|
||||
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||
)
|
||||
|
||||
// NewConfig returns a new constructed testcase config with specified testcase name.
|
||||
|
||||
@@ -1 +1 @@
|
||||
v4.3.0-beta-10101543
|
||||
v4.3.0-beta-10102150
|
||||
@@ -708,7 +708,6 @@ func (ud *uiaDriver) Input(text string, options ...DataOption) (err error) {
|
||||
return element.SendKeys(text, options...)
|
||||
}
|
||||
|
||||
|
||||
func (ud *uiaDriver) KeyboardDismiss(keyNames ...string) (err error) {
|
||||
// TODO
|
||||
return errDriverNotImplemented
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
@@ -72,7 +73,7 @@ func (ue uiaElement) TwoFingerTap() (err error) {
|
||||
}
|
||||
|
||||
func (ue uiaElement) TapWithNumberOfTaps(numberOfTaps, numberOfTouches int) (err error) {
|
||||
//Todo: implement
|
||||
// Todo: implement
|
||||
log.Fatal().Msg("not support")
|
||||
return
|
||||
}
|
||||
@@ -105,8 +105,6 @@ func WithDescription(description string) ActionOption {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
func WithMaxRetryTimes(maxRetryTimes int) ActionOption {
|
||||
return func(o *MobileAction) {
|
||||
o.MaxRetryTimes = maxRetryTimes
|
||||
@@ -508,7 +506,7 @@ func (dExt *DriverExt) DoAction(action MobileAction) error {
|
||||
options = append(options, WithCustomOption("description", action.Description))
|
||||
}
|
||||
if action.Identifier != "" {
|
||||
options = append(options,WithCustomOption("log", map[string]interface{}{
|
||||
options = append(options, WithCustomOption("log", map[string]interface{}{
|
||||
"enable": true,
|
||||
"data": action.Identifier,
|
||||
}))
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/json"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/uixt"
|
||||
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||
)
|
||||
|
||||
var fieldTags = []string{"proto", "status_code", "headers", "cookies", "body", textExtractorSubRegexp}
|
||||
|
||||
@@ -20,8 +20,8 @@ import (
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/uixt"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/version"
|
||||
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||
)
|
||||
|
||||
// Run starts to run API test with default configs.
|
||||
|
||||
@@ -3,7 +3,7 @@ package hrp
|
||||
import (
|
||||
giDevice "github.com/electricbubble/gidevice"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/uixt"
|
||||
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||
)
|
||||
|
||||
type StepType string
|
||||
|
||||
@@ -4,9 +4,10 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/uixt"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -189,10 +190,10 @@ func (s *StepAndroid) DoubleTap(params string, options ...uixt.ActionOption) *St
|
||||
return &StepAndroid{step: s.step}
|
||||
}
|
||||
|
||||
func (s *StepAndroid) Swipe(sx, sy, ex, ey int, options ...uixt.ActionOption) *StepAndroid {
|
||||
func (s *StepAndroid) Swipe(sx, sy, ex, ey float64, options ...uixt.ActionOption) *StepAndroid {
|
||||
action := uixt.MobileAction{
|
||||
Method: uixt.ACTION_Swipe,
|
||||
Params: []int{sx, sy, ex, ey},
|
||||
Params: []float64{sx, sy, ex, ey},
|
||||
}
|
||||
for _, option := range options {
|
||||
option(&action)
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/uixt"
|
||||
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -160,10 +160,10 @@ func (s *StepIOS) DoubleTap(params string, options ...uixt.ActionOption) *StepIO
|
||||
return &StepIOS{step: s.step}
|
||||
}
|
||||
|
||||
func (s *StepIOS) Swipe(sx, sy, ex, ey int, options ...uixt.ActionOption) *StepIOS {
|
||||
func (s *StepIOS) Swipe(sx, sy, ex, ey float64, options ...uixt.ActionOption) *StepIOS {
|
||||
action := uixt.MobileAction{
|
||||
Method: uixt.ACTION_Swipe,
|
||||
Params: []int{sx, sy, ex, ey},
|
||||
Params: []float64{sx, sy, ex, ey},
|
||||
}
|
||||
for _, option := range options {
|
||||
option(&action)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
__version__ = "v4.3.0-beta-10101543"
|
||||
__version__ = "v4.3.0-beta-10102150"
|
||||
__description__ = "One-stop solution for HTTP(S) testing."
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "httprunner"
|
||||
version = "v4.3.0-beta-10101543"
|
||||
version = "v4.3.0-beta-10102150"
|
||||
description = "One-stop solution for HTTP(S) testing."
|
||||
license = "Apache-2.0"
|
||||
readme = "README.md"
|
||||
|
||||
Reference in New Issue
Block a user