mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-12 03:09:43 +08:00
fix: panic by nil pointer
This commit is contained in:
@@ -8,5 +8,8 @@ import (
|
|||||||
|
|
||||||
func (dExt *DriverExt) Input(text string) (err error) {
|
func (dExt *DriverExt) Input(text string) (err error) {
|
||||||
err = dExt.Driver.Input(text)
|
err = dExt.Driver.Input(text)
|
||||||
return errors.Wrap(code.MobileUIInputError, err.Error())
|
if err != nil {
|
||||||
|
return errors.Wrap(code.MobileUIInputError, err.Error())
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,7 +172,6 @@ func (dExt *DriverExt) GetScreenShot(fileName string) (raw *bytes.Buffer, path s
|
|||||||
return nil, "", errors.Wrap(code.DeviceScreenShotError,
|
return nil, "", errors.Wrap(code.DeviceScreenShotError,
|
||||||
fmt.Sprintf("save screenshot file failed: %s", err.Error()))
|
fmt.Sprintf("save screenshot file failed: %s", err.Error()))
|
||||||
}
|
}
|
||||||
log.Debug().Str("path", path).Msg("save screenshot file success")
|
|
||||||
return compressed, path, nil
|
return compressed, path, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,10 @@ func (dExt *DriverExt) SwipeRelative(fromX, fromY, toX, toY float64, options ...
|
|||||||
toX = float64(width) * toX
|
toX = float64(width) * toX
|
||||||
toY = float64(height) * toY
|
toY = float64(height) * toY
|
||||||
err = dExt.Driver.SwipeFloat(fromX, fromY, toX, toY, options...)
|
err = dExt.Driver.SwipeFloat(fromX, fromY, toX, toY, options...)
|
||||||
return errors.Wrap(code.MobileUISwipeError, err.Error())
|
if err != nil {
|
||||||
|
return errors.Wrap(code.MobileUISwipeError, err.Error())
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dExt *DriverExt) SwipeTo(direction string, options ...ActionOption) (err error) {
|
func (dExt *DriverExt) SwipeTo(direction string, options ...ActionOption) (err error) {
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ import (
|
|||||||
func (dExt *DriverExt) TapAbsXY(x, y float64, options ...ActionOption) error {
|
func (dExt *DriverExt) TapAbsXY(x, y float64, options ...ActionOption) error {
|
||||||
// tap on absolute coordinate [x, y]
|
// tap on absolute coordinate [x, y]
|
||||||
err := dExt.Driver.TapFloat(x, y, options...)
|
err := dExt.Driver.TapFloat(x, y, options...)
|
||||||
return errors.Wrap(code.MobileUITapError, err.Error())
|
if err != nil {
|
||||||
|
return errors.Wrap(code.MobileUITapError, err.Error())
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dExt *DriverExt) TapXY(x, y float64, options ...ActionOption) error {
|
func (dExt *DriverExt) TapXY(x, y float64, options ...ActionOption) error {
|
||||||
@@ -88,7 +91,10 @@ func (dExt *DriverExt) DoubleTapXY(x, y float64, options ...ActionOption) error
|
|||||||
x = x * float64(windowSize.Width)
|
x = x * float64(windowSize.Width)
|
||||||
y = y * float64(windowSize.Height)
|
y = y * float64(windowSize.Height)
|
||||||
err = dExt.Driver.DoubleTapFloat(x, y, options...)
|
err = dExt.Driver.DoubleTapFloat(x, y, options...)
|
||||||
return errors.Wrap(code.MobileUITapError, err.Error())
|
if err != nil {
|
||||||
|
return errors.Wrap(code.MobileUITapError, err.Error())
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dExt *DriverExt) DoubleTap(param string, options ...ActionOption) (err error) {
|
func (dExt *DriverExt) DoubleTap(param string, options ...ActionOption) (err error) {
|
||||||
@@ -102,5 +108,8 @@ func (dExt *DriverExt) DoubleTapOffset(param string, xOffset, yOffset float64, o
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = dExt.Driver.DoubleTapFloat(point.X+xOffset, point.Y+yOffset, options...)
|
err = dExt.Driver.DoubleTapFloat(point.X+xOffset, point.Y+yOffset, options...)
|
||||||
return errors.Wrap(code.MobileUITapError, err.Error())
|
if err != nil {
|
||||||
|
return errors.Wrap(code.MobileUITapError, err.Error())
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user