mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-19 22:39:31 +08:00
feat: server支持自定义公共方法
This commit is contained in:
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/httprunner/httprunner/v5/pkg/uixt/option"
|
||||
)
|
||||
|
||||
func (r *Router) GetDriver(c *gin.Context) (driverExt uixt.IXTDriver, err error) {
|
||||
func (p RouterBaseMethod) GetDriver(c *gin.Context) (driverExt uixt.IXTDriver, err error) {
|
||||
deviceObj, exists := c.Get("device")
|
||||
var device uixt.IDevice
|
||||
var driver uixt.IDriver
|
||||
@@ -54,7 +54,6 @@ func GetDevice(c *gin.Context) (device uixt.IDevice, err error) {
|
||||
RenderErrorInitDriver(c, err)
|
||||
return
|
||||
}
|
||||
_ = device.Setup()
|
||||
case "ios":
|
||||
device, err = uixt.NewIOSDevice(
|
||||
option.WithUDID(serial),
|
||||
@@ -70,6 +69,10 @@ func GetDevice(c *gin.Context) (device uixt.IDevice, err error) {
|
||||
err = fmt.Errorf("[%s]: invalid platform", c.HandlerName())
|
||||
return
|
||||
}
|
||||
err = device.Setup()
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("setup device failed")
|
||||
}
|
||||
c.Set("device", device)
|
||||
return device, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user