refactor: use WithRelative to set relative coordinate, absolute by default

This commit is contained in:
lilong.129
2025-03-03 20:09:24 +08:00
parent 81a9562ffe
commit 359199a485
10 changed files with 51 additions and 22 deletions

View File

@@ -4,6 +4,7 @@ package uixt
import (
"testing"
"time"
"github.com/httprunner/httprunner/v5/pkg/uixt/ai"
"github.com/httprunner/httprunner/v5/pkg/uixt/option"
@@ -82,6 +83,34 @@ func setupDriverExt(t *testing.T) *XTDriver {
}
}
func TestDriverExt_FindScreenText(t *testing.T) {
driver := setupDriverExt(t)
point, err := driver.FindScreenText("首页")
assert.Nil(t, err)
t.Log(point)
}
func TestDriverExt_Seek(t *testing.T) {
driver := setupDriverExt(t)
point, err := driver.FindScreenText("首页")
assert.Nil(t, err)
size, err := driver.WindowSize()
assert.Nil(t, err)
width := size.Width
y := point.Y - 40
for i := 0; i < 5; i++ {
err := driver.Swipe(0.5, 0.8, 0.5, 0.2)
assert.Nil(t, err)
time.Sleep(1 * time.Second)
err = driver.Drag(20, y, float64(width)*0.75, y)
assert.Nil(t, err)
time.Sleep(1 * time.Second)
}
}
func TestDriverExt_TapByOCR(t *testing.T) {
driver := setupDriverExt(t)
err := driver.TapByOCR("天气")