mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-06 07:57:27 +08:00
feat: init device driver with plugin option
This commit is contained in:
@@ -170,15 +170,10 @@ func (dev *AndroidDevice) NewDriver(options ...DriverOption) (driverExt *DriverE
|
|||||||
return nil, errors.Wrap(err, "failed to init UIA driver")
|
return nil, errors.Wrap(err, "failed to init UIA driver")
|
||||||
}
|
}
|
||||||
|
|
||||||
driverExt, err = newDriverExt(dev, driver)
|
driverExt, err = newDriverExt(dev, driver, driverOptions.plugin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
err = driverExt.extendCV()
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(code.MobileUIDriverError,
|
|
||||||
fmt.Sprintf("extend OpenCV failed: %v", err))
|
|
||||||
}
|
|
||||||
|
|
||||||
if dev.LogOn {
|
if dev.LogOn {
|
||||||
err = driverExt.Driver.StartCaptureLog("hrp_adb_log")
|
err = driverExt.Driver.StartCaptureLog("hrp_adb_log")
|
||||||
|
|||||||
+10
-1
@@ -24,6 +24,7 @@ import (
|
|||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||||
|
"github.com/httprunner/httprunner/v4/hrp/internal/code"
|
||||||
"github.com/httprunner/httprunner/v4/hrp/internal/env"
|
"github.com/httprunner/httprunner/v4/hrp/internal/env"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -97,13 +98,21 @@ type DriverExt struct {
|
|||||||
plugin funplugin.IPlugin
|
plugin funplugin.IPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDriverExt(device Device, driver WebDriver) (dExt *DriverExt, err error) {
|
func newDriverExt(device Device, driver WebDriver, plugin funplugin.IPlugin) (dExt *DriverExt, err error) {
|
||||||
dExt = &DriverExt{
|
dExt = &DriverExt{
|
||||||
Device: device,
|
Device: device,
|
||||||
Driver: driver,
|
Driver: driver,
|
||||||
|
plugin: plugin,
|
||||||
cacheStepData: cacheStepData{},
|
cacheStepData: cacheStepData{},
|
||||||
interruptSignal: make(chan os.Signal, 1),
|
interruptSignal: make(chan os.Signal, 1),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = dExt.extendCV()
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(code.MobileUIDriverError,
|
||||||
|
fmt.Sprintf("extend OpenCV failed: %v", err))
|
||||||
|
}
|
||||||
|
|
||||||
dExt.cacheStepData.reset()
|
dExt.cacheStepData.reset()
|
||||||
signal.Notify(dExt.interruptSignal, syscall.SIGTERM, syscall.SIGINT)
|
signal.Notify(dExt.interruptSignal, syscall.SIGTERM, syscall.SIGINT)
|
||||||
dExt.doneMjpegStream = make(chan bool, 1)
|
dExt.doneMjpegStream = make(chan bool, 1)
|
||||||
|
|||||||
@@ -322,15 +322,11 @@ func (dev *IOSDevice) NewDriver(options ...DriverOption) (driverExt *DriverExt,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
driverExt, err = newDriverExt(dev, driver)
|
driverExt, err = newDriverExt(dev, driver, driverOptions.plugin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
err = driverExt.extendCV()
|
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(code.MobileUIDriverError,
|
|
||||||
fmt.Sprintf("extend OpenCV failed: %v", err))
|
|
||||||
}
|
|
||||||
settings, err := driverExt.Driver.SetAppiumSettings(map[string]interface{}{
|
settings, err := driverExt.Driver.SetAppiumSettings(map[string]interface{}{
|
||||||
"snapshotMaxDepth": dev.SnapshotMaxDepth,
|
"snapshotMaxDepth": dev.SnapshotMaxDepth,
|
||||||
"acceptAlertButtonSelector": dev.AcceptAlertButtonSelector,
|
"acceptAlertButtonSelector": dev.AcceptAlertButtonSelector,
|
||||||
|
|||||||
+2
-2
@@ -435,7 +435,7 @@ func (r *CaseRunner) parseConfig() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "init iOS device failed")
|
return errors.Wrap(err, "init iOS device failed")
|
||||||
}
|
}
|
||||||
client, err := device.NewDriver()
|
client, err := device.NewDriver(uixt.WithDriverPlugin(r.parser.plugin))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "init iOS WDA client failed")
|
return errors.Wrap(err, "init iOS WDA client failed")
|
||||||
}
|
}
|
||||||
@@ -454,7 +454,7 @@ func (r *CaseRunner) parseConfig() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "init Android device failed")
|
return errors.Wrap(err, "init Android device failed")
|
||||||
}
|
}
|
||||||
client, err := device.NewDriver()
|
client, err := device.NewDriver(uixt.WithDriverPlugin(r.parser.plugin))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "init Android client failed")
|
return errors.Wrap(err, "init Android client failed")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -538,7 +538,7 @@ func (r *CaseRunner) initUIClient(uuid string, osType string) (client *uixt.Driv
|
|||||||
return nil, errors.Wrapf(err, "init %s device failed", osType)
|
return nil, errors.Wrapf(err, "init %s device failed", osType)
|
||||||
}
|
}
|
||||||
|
|
||||||
client, err = device.NewDriver()
|
client, err = device.NewDriver(uixt.WithDriverPlugin(r.parser.plugin))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user