diff --git a/examples/uixt/demo_test.go b/examples/uixt/demo_test.go new file mode 100644 index 00000000..44e29248 --- /dev/null +++ b/examples/uixt/demo_test.go @@ -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) + } + } +} diff --git a/hrp/cmd/adb/devices.go b/hrp/cmd/adb/devices.go index 789bc1e4..7cd53b69 100644 --- a/hrp/cmd/adb/devices.go +++ b/hrp/cmd/adb/devices.go @@ -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 { diff --git a/hrp/cmd/ios/devices.go b/hrp/cmd/ios/devices.go index 58484e1f..0553d82a 100644 --- a/hrp/cmd/ios/devices.go +++ b/hrp/cmd/ios/devices.go @@ -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 { diff --git a/hrp/cmd/ios/init.go b/hrp/cmd/ios/init.go index 8cfea1f3..db1f63a9 100644 --- a/hrp/cmd/ios/init.go +++ b/hrp/cmd/ios/init.go @@ -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{ diff --git a/hrp/config.go b/hrp/config.go index 3d1e1aa1..9c03278f 100644 --- a/hrp/config.go +++ b/hrp/config.go @@ -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. diff --git a/hrp/internal/version/VERSION b/hrp/internal/version/VERSION index 8d5575f6..5c7cda41 100644 --- a/hrp/internal/version/VERSION +++ b/hrp/internal/version/VERSION @@ -1 +1 @@ -v4.3.0-beta-10101543 \ No newline at end of file +v4.3.0-beta-10102150 \ No newline at end of file diff --git a/hrp/internal/uixt/README.md b/hrp/pkg/uixt/README.md similarity index 100% rename from hrp/internal/uixt/README.md rename to hrp/pkg/uixt/README.md diff --git a/hrp/internal/uixt/android_action.go b/hrp/pkg/uixt/android_action.go similarity index 100% rename from hrp/internal/uixt/android_action.go rename to hrp/pkg/uixt/android_action.go diff --git a/hrp/internal/uixt/android_device.go b/hrp/pkg/uixt/android_device.go similarity index 100% rename from hrp/internal/uixt/android_device.go rename to hrp/pkg/uixt/android_device.go diff --git a/hrp/internal/uixt/android_device_test.go b/hrp/pkg/uixt/android_device_test.go similarity index 100% rename from hrp/internal/uixt/android_device_test.go rename to hrp/pkg/uixt/android_device_test.go diff --git a/hrp/internal/uixt/android_driver.go b/hrp/pkg/uixt/android_driver.go similarity index 99% rename from hrp/internal/uixt/android_driver.go rename to hrp/pkg/uixt/android_driver.go index cb39fd78..58073906 100644 --- a/hrp/internal/uixt/android_driver.go +++ b/hrp/pkg/uixt/android_driver.go @@ -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 diff --git a/hrp/internal/uixt/android_elment.go b/hrp/pkg/uixt/android_elment.go similarity index 99% rename from hrp/internal/uixt/android_elment.go rename to hrp/pkg/uixt/android_elment.go index 27c503df..e03c792d 100644 --- a/hrp/internal/uixt/android_elment.go +++ b/hrp/pkg/uixt/android_elment.go @@ -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 } diff --git a/hrp/internal/uixt/android_key.go b/hrp/pkg/uixt/android_key.go similarity index 100% rename from hrp/internal/uixt/android_key.go rename to hrp/pkg/uixt/android_key.go diff --git a/hrp/internal/uixt/android_test.go b/hrp/pkg/uixt/android_test.go similarity index 100% rename from hrp/internal/uixt/android_test.go rename to hrp/pkg/uixt/android_test.go diff --git a/hrp/internal/uixt/client.go b/hrp/pkg/uixt/client.go similarity index 100% rename from hrp/internal/uixt/client.go rename to hrp/pkg/uixt/client.go diff --git a/hrp/internal/uixt/drag.go b/hrp/pkg/uixt/drag.go similarity index 100% rename from hrp/internal/uixt/drag.go rename to hrp/pkg/uixt/drag.go diff --git a/hrp/internal/uixt/drag_test.go b/hrp/pkg/uixt/drag_test.go similarity index 100% rename from hrp/internal/uixt/drag_test.go rename to hrp/pkg/uixt/drag_test.go diff --git a/hrp/internal/uixt/ext.go b/hrp/pkg/uixt/ext.go similarity index 99% rename from hrp/internal/uixt/ext.go rename to hrp/pkg/uixt/ext.go index 2c24a815..babc74fc 100644 --- a/hrp/internal/uixt/ext.go +++ b/hrp/pkg/uixt/ext.go @@ -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, })) diff --git a/hrp/internal/uixt/gesture.go b/hrp/pkg/uixt/gesture.go similarity index 100% rename from hrp/internal/uixt/gesture.go rename to hrp/pkg/uixt/gesture.go diff --git a/hrp/internal/uixt/gesture_test.go b/hrp/pkg/uixt/gesture_test.go similarity index 100% rename from hrp/internal/uixt/gesture_test.go rename to hrp/pkg/uixt/gesture_test.go diff --git a/hrp/internal/uixt/interface.go b/hrp/pkg/uixt/interface.go similarity index 100% rename from hrp/internal/uixt/interface.go rename to hrp/pkg/uixt/interface.go diff --git a/hrp/internal/uixt/ios_action.go b/hrp/pkg/uixt/ios_action.go similarity index 100% rename from hrp/internal/uixt/ios_action.go rename to hrp/pkg/uixt/ios_action.go diff --git a/hrp/internal/uixt/ios_device.go b/hrp/pkg/uixt/ios_device.go similarity index 100% rename from hrp/internal/uixt/ios_device.go rename to hrp/pkg/uixt/ios_device.go diff --git a/hrp/internal/uixt/ios_driver.go b/hrp/pkg/uixt/ios_driver.go similarity index 100% rename from hrp/internal/uixt/ios_driver.go rename to hrp/pkg/uixt/ios_driver.go diff --git a/hrp/internal/uixt/ios_element.go b/hrp/pkg/uixt/ios_element.go similarity index 100% rename from hrp/internal/uixt/ios_element.go rename to hrp/pkg/uixt/ios_element.go diff --git a/hrp/internal/uixt/ios_test.go b/hrp/pkg/uixt/ios_test.go similarity index 100% rename from hrp/internal/uixt/ios_test.go rename to hrp/pkg/uixt/ios_test.go diff --git a/hrp/internal/uixt/ocr_off.go b/hrp/pkg/uixt/ocr_off.go similarity index 100% rename from hrp/internal/uixt/ocr_off.go rename to hrp/pkg/uixt/ocr_off.go diff --git a/hrp/internal/uixt/ocr_on.go b/hrp/pkg/uixt/ocr_on.go similarity index 100% rename from hrp/internal/uixt/ocr_on.go rename to hrp/pkg/uixt/ocr_on.go diff --git a/hrp/internal/uixt/ocr_test.go b/hrp/pkg/uixt/ocr_test.go similarity index 100% rename from hrp/internal/uixt/ocr_test.go rename to hrp/pkg/uixt/ocr_test.go diff --git a/hrp/internal/uixt/opencv_off.go b/hrp/pkg/uixt/opencv_off.go similarity index 100% rename from hrp/internal/uixt/opencv_off.go rename to hrp/pkg/uixt/opencv_off.go diff --git a/hrp/internal/uixt/opencv_on.go b/hrp/pkg/uixt/opencv_on.go similarity index 100% rename from hrp/internal/uixt/opencv_on.go rename to hrp/pkg/uixt/opencv_on.go diff --git a/hrp/internal/uixt/swipe.go b/hrp/pkg/uixt/swipe.go similarity index 100% rename from hrp/internal/uixt/swipe.go rename to hrp/pkg/uixt/swipe.go diff --git a/hrp/internal/uixt/swipe_test.go b/hrp/pkg/uixt/swipe_test.go similarity index 100% rename from hrp/internal/uixt/swipe_test.go rename to hrp/pkg/uixt/swipe_test.go diff --git a/hrp/internal/uixt/tap.go b/hrp/pkg/uixt/tap.go similarity index 100% rename from hrp/internal/uixt/tap.go rename to hrp/pkg/uixt/tap.go diff --git a/hrp/internal/uixt/tap_test.go b/hrp/pkg/uixt/tap_test.go similarity index 100% rename from hrp/internal/uixt/tap_test.go rename to hrp/pkg/uixt/tap_test.go diff --git a/hrp/internal/uixt/touch.go b/hrp/pkg/uixt/touch.go similarity index 100% rename from hrp/internal/uixt/touch.go rename to hrp/pkg/uixt/touch.go diff --git a/hrp/internal/uixt/touch_test.go b/hrp/pkg/uixt/touch_test.go similarity index 100% rename from hrp/internal/uixt/touch_test.go rename to hrp/pkg/uixt/touch_test.go diff --git a/hrp/response.go b/hrp/response.go index 33fe48e7..5f28b269 100644 --- a/hrp/response.go +++ b/hrp/response.go @@ -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} diff --git a/hrp/runner.go b/hrp/runner.go index 13dced72..a587adc1 100644 --- a/hrp/runner.go +++ b/hrp/runner.go @@ -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. diff --git a/hrp/step.go b/hrp/step.go index 3cdeaeb5..9f6989eb 100644 --- a/hrp/step.go +++ b/hrp/step.go @@ -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 diff --git a/hrp/step_android_ui.go b/hrp/step_android_ui.go index 8fffc533..8c175c21 100644 --- a/hrp/step_android_ui.go +++ b/hrp/step_android_ui.go @@ -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) diff --git a/hrp/step_ios_ui.go b/hrp/step_ios_ui.go index 828dbbbf..7ba60103 100644 --- a/hrp/step_ios_ui.go +++ b/hrp/step_ios_ui.go @@ -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) diff --git a/httprunner/__init__.py b/httprunner/__init__.py index 4e71d36a..563312e8 100644 --- a/httprunner/__init__.py +++ b/httprunner/__init__.py @@ -1,4 +1,4 @@ -__version__ = "v4.3.0-beta-10101543" +__version__ = "v4.3.0-beta-10102150" __description__ = "One-stop solution for HTTP(S) testing." diff --git a/pyproject.toml b/pyproject.toml index 0fe8271b..8b34acba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"