mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 19:47:14 +08:00
refactor: move uixt from hrp internal to pkg
This commit is contained in:
@@ -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/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"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 {
|
func format(data map[string]string) string {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/uixt"
|
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Device struct {
|
type Device struct {
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ import (
|
|||||||
giDevice "github.com/electricbubble/gidevice"
|
giDevice "github.com/electricbubble/gidevice"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/uixt"
|
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||||
)
|
)
|
||||||
|
|
||||||
var iosRootCmd = &cobra.Command{
|
var iosRootCmd = &cobra.Command{
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
"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.
|
// 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...)
|
return element.SendKeys(text, options...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (ud *uiaDriver) KeyboardDismiss(keyNames ...string) (err error) {
|
func (ud *uiaDriver) KeyboardDismiss(keyNames ...string) (err error) {
|
||||||
// TODO
|
// TODO
|
||||||
return errDriverNotImplemented
|
return errDriverNotImplemented
|
||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
@@ -72,7 +73,7 @@ func (ue uiaElement) TwoFingerTap() (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ue uiaElement) TapWithNumberOfTaps(numberOfTaps, numberOfTouches int) (err error) {
|
func (ue uiaElement) TapWithNumberOfTaps(numberOfTaps, numberOfTouches int) (err error) {
|
||||||
//Todo: implement
|
// Todo: implement
|
||||||
log.Fatal().Msg("not support")
|
log.Fatal().Msg("not support")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -105,8 +105,6 @@ func WithDescription(description string) ActionOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func WithMaxRetryTimes(maxRetryTimes int) ActionOption {
|
func WithMaxRetryTimes(maxRetryTimes int) ActionOption {
|
||||||
return func(o *MobileAction) {
|
return func(o *MobileAction) {
|
||||||
o.MaxRetryTimes = maxRetryTimes
|
o.MaxRetryTimes = maxRetryTimes
|
||||||
@@ -508,7 +506,7 @@ func (dExt *DriverExt) DoAction(action MobileAction) error {
|
|||||||
options = append(options, WithCustomOption("description", action.Description))
|
options = append(options, WithCustomOption("description", action.Description))
|
||||||
}
|
}
|
||||||
if action.Identifier != "" {
|
if action.Identifier != "" {
|
||||||
options = append(options,WithCustomOption("log", map[string]interface{}{
|
options = append(options, WithCustomOption("log", map[string]interface{}{
|
||||||
"enable": true,
|
"enable": true,
|
||||||
"data": action.Identifier,
|
"data": action.Identifier,
|
||||||
}))
|
}))
|
||||||
+1
-1
@@ -16,7 +16,7 @@ import (
|
|||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/json"
|
"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}
|
var fieldTags = []string{"proto", "status_code", "headers", "cookies", "body", textExtractorSubRegexp}
|
||||||
|
|||||||
+1
-1
@@ -20,8 +20,8 @@ import (
|
|||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/sdk"
|
"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/internal/version"
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Run starts to run API test with default configs.
|
// Run starts to run API test with default configs.
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ package hrp
|
|||||||
import (
|
import (
|
||||||
giDevice "github.com/electricbubble/gidevice"
|
giDevice "github.com/electricbubble/gidevice"
|
||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/uixt"
|
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||||
)
|
)
|
||||||
|
|
||||||
type StepType string
|
type StepType string
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/uixt"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -189,10 +190,10 @@ func (s *StepAndroid) DoubleTap(params string, options ...uixt.ActionOption) *St
|
|||||||
return &StepAndroid{step: s.step}
|
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{
|
action := uixt.MobileAction{
|
||||||
Method: uixt.ACTION_Swipe,
|
Method: uixt.ACTION_Swipe,
|
||||||
Params: []int{sx, sy, ex, ey},
|
Params: []float64{sx, sy, ex, ey},
|
||||||
}
|
}
|
||||||
for _, option := range options {
|
for _, option := range options {
|
||||||
option(&action)
|
option(&action)
|
||||||
|
|||||||
+3
-3
@@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/uixt"
|
"github.com/httprunner/httprunner/v4/hrp/pkg/uixt"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -160,10 +160,10 @@ func (s *StepIOS) DoubleTap(params string, options ...uixt.ActionOption) *StepIO
|
|||||||
return &StepIOS{step: s.step}
|
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{
|
action := uixt.MobileAction{
|
||||||
Method: uixt.ACTION_Swipe,
|
Method: uixt.ACTION_Swipe,
|
||||||
Params: []int{sx, sy, ex, ey},
|
Params: []float64{sx, sy, ex, ey},
|
||||||
}
|
}
|
||||||
for _, option := range options {
|
for _, option := range options {
|
||||||
option(&action)
|
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."
|
__description__ = "One-stop solution for HTTP(S) testing."
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "httprunner"
|
name = "httprunner"
|
||||||
version = "v4.3.0-beta-10101543"
|
version = "v4.3.0-beta-10102150"
|
||||||
description = "One-stop solution for HTTP(S) testing."
|
description = "One-stop solution for HTTP(S) testing."
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|||||||
Reference in New Issue
Block a user