mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 11:29:48 +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")
|
||||
}
|
||||
|
||||
driverExt, err = newDriverExt(dev, driver)
|
||||
driverExt, err = newDriverExt(dev, driver, driverOptions.plugin)
|
||||
if err != nil {
|
||||
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 {
|
||||
err = driverExt.Driver.StartCaptureLog("hrp_adb_log")
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/builtin"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/code"
|
||||
"github.com/httprunner/httprunner/v4/hrp/internal/env"
|
||||
)
|
||||
|
||||
@@ -97,13 +98,21 @@ type DriverExt struct {
|
||||
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{
|
||||
Device: device,
|
||||
Driver: driver,
|
||||
plugin: plugin,
|
||||
cacheStepData: cacheStepData{},
|
||||
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()
|
||||
signal.Notify(dExt.interruptSignal, syscall.SIGTERM, syscall.SIGINT)
|
||||
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 {
|
||||
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{}{
|
||||
"snapshotMaxDepth": dev.SnapshotMaxDepth,
|
||||
"acceptAlertButtonSelector": dev.AcceptAlertButtonSelector,
|
||||
|
||||
@@ -435,7 +435,7 @@ func (r *CaseRunner) parseConfig() error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "init iOS device failed")
|
||||
}
|
||||
client, err := device.NewDriver()
|
||||
client, err := device.NewDriver(uixt.WithDriverPlugin(r.parser.plugin))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "init iOS WDA client failed")
|
||||
}
|
||||
@@ -454,7 +454,7 @@ func (r *CaseRunner) parseConfig() error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "init Android device failed")
|
||||
}
|
||||
client, err := device.NewDriver()
|
||||
client, err := device.NewDriver(uixt.WithDriverPlugin(r.parser.plugin))
|
||||
if err != nil {
|
||||
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)
|
||||
}
|
||||
|
||||
client, err = device.NewDriver()
|
||||
client, err = device.NewDriver(uixt.WithDriverPlugin(r.parser.plugin))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user