fix: WDADriver

This commit is contained in:
lilong.129
2025-02-10 22:32:58 +08:00
parent 3d67bfba62
commit 7b16ad62ee
9 changed files with 90 additions and 136 deletions

View File

@@ -111,14 +111,6 @@ func (s *ShootsIOSDriver) DeviceInfo() (types.DeviceInfo, error) {
return s.WDADriver.DeviceInfo()
}
func (s *ShootsIOSDriver) Location() (types.Location, error) {
err := s.setUpWda()
if err != nil {
return types.Location{}, err
}
return s.WDADriver.Location()
}
func (s *ShootsIOSDriver) BatteryInfo() (types.BatteryInfo, error) {
err := s.setUpWda()
if err != nil {
@@ -456,7 +448,7 @@ func (s *ShootsIOSDriver) GetDriverResults() []*uixt.DriverRequests {
}
func (s *ShootsIOSDriver) Source(srcOpt ...option.SourceOption) (string, error) {
resp, err := s.Request(http.MethodGet, fmt.Sprintf("%s/source?format=json&onlyWeb=false", s.bightInsightPrefix), []byte{})
resp, err := s.Session.Request(http.MethodGet, fmt.Sprintf("%s/source?format=json&onlyWeb=false", s.bightInsightPrefix), []byte{})
if err != nil {
return "", err
}
@@ -478,7 +470,7 @@ func (s *ShootsIOSDriver) LoginNoneUI(packageName, phoneNumber string, captcha,
if err != nil {
return info, err
}
resp, err := s.Request(http.MethodPost, fmt.Sprintf("%s/host/login/account/", s.serverPrefix), bsJSON)
resp, err := s.Session.Request(http.MethodPost, fmt.Sprintf("%s/host/login/account/", s.serverPrefix), bsJSON)
if err != nil {
return info, err
}
@@ -502,7 +494,7 @@ func (s *ShootsIOSDriver) LoginNoneUI(packageName, phoneNumber string, captcha,
}
func (s *ShootsIOSDriver) LogoutNoneUI(packageName string) error {
resp, err := s.Request(http.MethodGet, fmt.Sprintf("%s/host/loginout/", s.serverPrefix), []byte{})
resp, err := s.Session.Request(http.MethodGet, fmt.Sprintf("%s/host/loginout/", s.serverPrefix), []byte{})
if err != nil {
return err
}
@@ -526,7 +518,7 @@ func (s *ShootsIOSDriver) TearDown() error {
}
func (s *ShootsIOSDriver) getLoginAppInfo(packageName string) (info AppLoginInfo, err error) {
resp, err := s.Request(http.MethodGet, fmt.Sprintf("%s/host/app/info/", s.serverPrefix), []byte{})
resp, err := s.Session.Request(http.MethodGet, fmt.Sprintf("%s/host/app/info/", s.serverPrefix), []byte{})
if err != nil {
return info, err
}

View File

@@ -12,7 +12,7 @@ import (
)
var (
shootsIOSDriver uixt.IDriverExt
shootsIOSDriver uixt.IDriver
iOSDevice *uixt.IOSDevice
)
@@ -22,7 +22,7 @@ func setupShootsIOSDriver(t *testing.T) {
option.WithWDAPort(8700),
option.WithWDAMjpegPort(8800))
checkErr(t, err)
shootsIOSDriver, err = iOSDevice.NewDriver()
shootsIOSDriver, err = NewShootsIOSDriver(iOSDevice)
checkErr(t, err)
}
@@ -47,31 +47,31 @@ func TestIOSIsLogin(t *testing.T) {
func TestIOSSource(t *testing.T) {
setupShootsIOSDriver(t)
source, err := shootsIOSDriver.GetDriver().Source()
source, err := shootsIOSDriver.Source()
checkErr(t, err)
t.Log(source)
}
func TestIOSForeground(t *testing.T) {
setupShootsIOSDriver(t)
app, err := shootsIOSDriver.GetDriver().GetForegroundApp()
app, err := shootsIOSDriver.GetForegroundApp()
checkErr(t, err)
t.Log(app)
}
func TestIOSSwipe(t *testing.T) {
setupShootsIOSDriver(t)
shootsIOSDriver.GetDriver().Swipe(540, 0, 540, 1000)
shootsIOSDriver.Swipe(540, 0, 540, 1000)
}
func TestIOSSave(t *testing.T) {
setupShootsIOSDriver(t)
raw, err := shootsIOSDriver.GetDriver().Screenshot()
raw, err := shootsIOSDriver.Screenshot()
if err != nil {
t.Fatal(err)
}
source, err := shootsIOSDriver.GetDriver().Source()
source, err := shootsIOSDriver.Source()
if err != nil {
t.Fatal(err)
}