mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 19:47:14 +08:00
fix: avoid recreate driver in tests
This commit is contained in:
+36
-18
@@ -16,29 +16,47 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func setupADBDriverExt(t *testing.T) *XTDriver {
|
func setupADBDriverExt(t *testing.T) *XTDriver {
|
||||||
device, err := NewAndroidDevice()
|
config := DriverCacheConfig{
|
||||||
require.Nil(t, err)
|
Platform: "android",
|
||||||
device.Options.UIA2 = false
|
Serial: "", // Let it auto-detect the device serial
|
||||||
device.Options.LogOn = false
|
AIOptions: []option.AIServiceOption{
|
||||||
driver, err := device.NewDriver()
|
option.WithCVService(option.CVServiceTypeVEDEM),
|
||||||
require.Nil(t, err)
|
option.WithLLMConfig(
|
||||||
driverExt, err := NewXTDriver(driver,
|
option.NewLLMServiceConfig(option.DOUBAO_1_5_UI_TARS_250328).
|
||||||
option.WithCVService(option.CVServiceTypeVEDEM),
|
WithPlannerModel(option.WINGS_SERVICE).
|
||||||
// option.WithLLMService(option.DOUBAO_1_5_UI_TARS_250328),
|
WithAsserterModel(option.WINGS_SERVICE),
|
||||||
)
|
),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
driverExt, err := GetOrCreateXTDriver(config)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
return driverExt
|
return driverExt
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupUIA2DriverExt(t *testing.T) *XTDriver {
|
func setupUIA2DriverExt(t *testing.T) *XTDriver {
|
||||||
device, err := NewAndroidDevice()
|
// Use cache mechanism with UIA2 enabled
|
||||||
require.Nil(t, err)
|
deviceOpts := option.NewDeviceOptions(
|
||||||
device.Options.UIA2 = true // use uiautomator2 driver
|
option.WithPlatform("android"),
|
||||||
device.Options.LogOn = false
|
option.WithDeviceUIA2(true),
|
||||||
driver, err := device.NewDriver()
|
option.WithDeviceLogOn(false),
|
||||||
require.Nil(t, err)
|
)
|
||||||
driverExt, err := NewXTDriver(driver,
|
|
||||||
option.WithCVService(option.CVServiceTypeVEDEM))
|
config := DriverCacheConfig{
|
||||||
|
Platform: "android",
|
||||||
|
Serial: "", // Let it auto-detect the device serial
|
||||||
|
DeviceOpts: deviceOpts,
|
||||||
|
AIOptions: []option.AIServiceOption{
|
||||||
|
option.WithCVService(option.CVServiceTypeVEDEM),
|
||||||
|
option.WithLLMConfig(
|
||||||
|
option.NewLLMServiceConfig(option.DOUBAO_1_5_UI_TARS_250328).
|
||||||
|
WithPlannerModel(option.WINGS_SERVICE).
|
||||||
|
WithAsserterModel(option.WINGS_SERVICE),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
driverExt, err := GetOrCreateXTDriver(config)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
return driverExt
|
return driverExt
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-6
@@ -5,17 +5,28 @@ package uixt
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/httprunner/httprunner/v5/uixt/option"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/httprunner/httprunner/v5/uixt/option"
|
||||||
)
|
)
|
||||||
|
|
||||||
func setupHDCDriverExt(t *testing.T) *XTDriver {
|
func setupHDCDriverExt(t *testing.T) *XTDriver {
|
||||||
device, err := NewHarmonyDevice()
|
// Use cache mechanism for Harmony HDC driver
|
||||||
require.Nil(t, err)
|
config := DriverCacheConfig{
|
||||||
hdcDriver, err := NewHDCDriver(device)
|
Platform: "harmony",
|
||||||
require.Nil(t, err)
|
Serial: "", // Let it auto-detect the device serial
|
||||||
driverExt, err := NewXTDriver(hdcDriver, option.WithCVService(option.CVServiceTypeVEDEM))
|
AIOptions: []option.AIServiceOption{
|
||||||
|
option.WithCVService(option.CVServiceTypeVEDEM),
|
||||||
|
option.WithLLMConfig(
|
||||||
|
option.NewLLMServiceConfig(option.DOUBAO_1_5_UI_TARS_250328).
|
||||||
|
WithPlannerModel(option.WINGS_SERVICE).
|
||||||
|
WithAsserterModel(option.WINGS_SERVICE),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
driverExt, err := GetOrCreateXTDriver(config)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
return driverExt
|
return driverExt
|
||||||
}
|
}
|
||||||
|
|||||||
+23
-8
@@ -16,14 +16,29 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func setupWDADriverExt(t *testing.T) *XTDriver {
|
func setupWDADriverExt(t *testing.T) *XTDriver {
|
||||||
device, err := NewIOSDevice(
|
// Use cache mechanism with unified DeviceOptions for iOS WDA driver
|
||||||
option.WithWDAPort(8700),
|
deviceOpts := option.NewDeviceOptions(
|
||||||
option.WithWDAMjpegPort(8800),
|
option.WithPlatform("ios"),
|
||||||
option.WithWDALogOn(true))
|
option.WithDeviceWDAPort(8700),
|
||||||
require.Nil(t, err)
|
option.WithDeviceWDAMjpegPort(8800),
|
||||||
driver, err := device.NewDriver()
|
option.WithDeviceLogOn(true),
|
||||||
require.Nil(t, err)
|
)
|
||||||
driverExt, err := NewXTDriver(driver, option.WithCVService(option.CVServiceTypeVEDEM))
|
|
||||||
|
config := DriverCacheConfig{
|
||||||
|
Platform: "ios",
|
||||||
|
Serial: "", // Let it auto-detect the device serial
|
||||||
|
DeviceOpts: deviceOpts,
|
||||||
|
AIOptions: []option.AIServiceOption{
|
||||||
|
option.WithCVService(option.CVServiceTypeVEDEM),
|
||||||
|
option.WithLLMConfig(
|
||||||
|
option.NewLLMServiceConfig(option.DOUBAO_1_5_UI_TARS_250328).
|
||||||
|
WithPlannerModel(option.WINGS_SERVICE).
|
||||||
|
WithAsserterModel(option.WINGS_SERVICE),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
driverExt, err := GetOrCreateXTDriver(config)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
return driverExt
|
return driverExt
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user